0% found this document useful (0 votes)
8 views

AI PRACTICAL FILE-1

ai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

AI PRACTICAL FILE-1

ai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

PM SHRI KENDRIYA VIDYALAYA NO.

2 NEEMUCH

ARTIFICIAL INTELLIGENCE (417)

PRACTICAL FILE SESSION 2024-25

SUBMITTED BY:

NAME: -
Class - X
CBSE Roll No -
Practical 1. Print 5 lines about yourself using print() function.

Program: -
print("Hello, my name is Rajesh.")
print("I love coding and solving problems.")
print("My favorite subject is Artificial Intelligence.")
print("I enjoy reading books in my free time.")
print("I aspire to become a data scientist.")

Output:
Hello, my name is Alex.
I love coding and solving problems.
My favorite subject is Artificial Intelligence.
I enjoy reading books in my free time.
I aspire to become a data scientist.
Practical 2. Calculate energy using this formula: energy = mgh. m =
mass in kg, g = 9.8 acceleration due to gravity in m/s^2, h = height in
meters

Program: -
m = 10
g = 9.8
h=5
energy = m * g * h
print("Energy: ", energy, "Joules")

Output:
Energy: 490.0 Joules
Practical 3. Program to calculate speed based on distance and time.

Program: -

distance = 100
time = 20
speed = distance / time
print("Speed:", speed, "m/s")

Output:
Speed: 5.0 m/s
Practical 4. Demonstrate the use of floor division (//) and modulo
operator (%) in Python

Program: -

a = 17
b=4
print("Floor division (17 // 4):", a // b)
print("Modulo (17 % 4):", a % b)

Output:
Floor division (17 // 4): 4
Modulo (17 % 4): 1
Practical 5. Lock or unlock your phone using pin or password and
generate appropriate message

Program: -

pin = "1234"
entered_pin = input("Enter your PIN: ")
if entered_pin == pin:
print("Phone unlocked.")
else:
print("Incorrect PIN. Phone locked.")

Output (example):
Enter your PIN: 1234
Phone unlocked.
Practical 6. Check whether the entered number is odd or even.

Program: -

num = int(input("Enter a number: "))


if num % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")

Output (example):
Enter a number: 7
The number is odd.
Practical 7. Tours and travels company charges based on customer
category.

Program: -

category = input("Enter customer category (Adult/Child/Senior):


").lower()
if category == "adult":
charge = 10000
if category == "child":
charge = 5000
if category == "senior":
charge = 7000
print("Charge: ", charge, "Rupees")

Output (example):
Enter customer category (Adult/Child/Senior): child
Charge: 50 Rupees
Practical 8. Increment to employees based on their appraisal score.

Program: -

score = float(input("Enter appraisal score: "))


if score >= 4.5:
increment = 20
elif score >= 3.5:
increment = 15
elif score >= 2.5:
increment = 10
else:
increment = 5
print("Increment percentage: ", increment, "%")

Output (example):
Enter appraisal score: 4.0
Increment percentage: 15 %
Practical 9. Python program to reverse a string using slicing.

Program: -

string = "Hello, World!"


reversed_string = string[::-1]
print("Reversed string:", reversed_string)

Output (example):
Reversed string: !dlroW ,olleH
Practical 10. Print a multiplication table of entered number.

Program: -

num = int(input("Enter a number: "))


for i in range(1, 11):
print(num, "x", i, "=", num * i)

Output (example):
Enter a number: 5
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
Practical 11. Find sum of first N numbers.

Program: -

N = int(input("Enter a number: "))


sum_of_numbers = 0
for i in range(1, N + 1):
sum_of_numbers = sum_of_numbers + i

print("Sum of first", N, "numbers:", sum_of_numbers)

Output (example):
Enter a number: 5
Sum of first 5 numbers: 15
Practical 12. Find average of first N numbers.

Program: -

N = int(input("Enter a number: "))


sum_of_numbers = 0
for i in range(1, N + 1):
sum_of_numbers += i
average = sum_of_numbers / N
print("Average of first", N, "numbers:", average)

Output (example):
Enter a number: 5
Average of first 5 numbers: 3.0
Practical 13. Find average of odd numbers from the selected range of
N numbers.

Program: -

N = int(input("Enter the value of N: "))


sum_odd = 0
count = 0
for i in range(1, N + 1):
if i % 2 != 0:
sum_odd += i
count += 1
if count > 0:
average_odd = sum_odd / count
print("Average of odd numbers from 1 to", N, "is:", average_odd)
else:
print("No odd numbers in the range.")

Output (example):
Enter the value of N: 10
Average of odd numbers from 1 to 10 is: 5.0
Practical 14. Find the factorial of a number.
Program: -

num = int(input("Enter a number: "))


factorial = 1
for i in range(1, num + 1):
factorial = factorial * i
print("Factorial of", num, "is:", factorial)

Output (example):
Enter a number: 5
Factorial of 5 is: 120
Practical 15. Python program to extract every second character from
the string, starting from index 0.

Program: -

string = input("Enter a string: ")


even_place_chars = string[::2]
print("Characters at even places:", even_place_chars)

Output (example):
Enter a string: Hello, World!
Characters at even places: Hlo ol!
Practical 16. Check whether a year is a leap year or not.

Program: -

year = int(input("Enter a year: "))


if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("The year is a leap year.")
else:
print("The year is not a leap year.")

Output (example):
Enter a year: 2024
The year is a leap year.
Practical 17. Check if a number is positive, negative, or zero.

Program: -

num = int(input("Enter a number: "))


if num > 0:
print("The number is positive.")
else:
if num < 0:
print("The number is negative.")
else:
print("The number is zero.")

Output (example):
Enter a number: -5
The number is negative.
Practical 18. Find the area of a rectangle.

Program: -

length = float(input("Enter length of the rectangle: "))


breadth = float(input("Enter breadth of the rectangle: "))
area = length * breadth
print("Area of the rectangle:", area)

Output (example):
Enter length of the rectangle: 5
Enter breadth of the rectangle: 4
Area of the rectangle: 20.0
Practical 19. Calculate the square of a number.

Program: -

num = int(input("Enter a number: "))


square = num ** 2
print("Square of", num, "is:", square)

Output (example):
Enter a number: 7
Square of 7 is: 49
Practical 20. Calculate the perimeter of a circle.
Program: -

radius = float(input("Enter radius of the circle: "))


pi = 3.14159
perimeter = 2 * pi * radius
print("Perimeter of the circle:", perimeter)

Output (example):
Enter radius of the circle: 5
Perimeter of the circle: 31.4159

www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com
www.cbseportal.com

You might also like