AI PRACTICAL FILE-1
AI PRACTICAL FILE-1
2 NEEMUCH
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: -
Output (example):
Enter a number: 7
The number is odd.
Practical 7. Tours and travels company charges based on customer
category.
Program: -
Output (example):
Enter customer category (Adult/Child/Senior): child
Charge: 50 Rupees
Practical 8. Increment to employees based on their appraisal score.
Program: -
Output (example):
Enter appraisal score: 4.0
Increment percentage: 15 %
Practical 9. Python program to reverse a string using slicing.
Program: -
Output (example):
Reversed string: !dlroW ,olleH
Practical 10. Print a multiplication table of entered number.
Program: -
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: -
Output (example):
Enter a number: 5
Sum of first 5 numbers: 15
Practical 12. Find average of first N numbers.
Program: -
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: -
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: -
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: -
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: -
Output (example):
Enter a year: 2024
The year is a leap year.
Practical 17. Check if a number is positive, negative, or zero.
Program: -
Output (example):
Enter a number: -5
The number is negative.
Practical 18. Find the area of a rectangle.
Program: -
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: -
Output (example):
Enter a number: 7
Square of 7 is: 49
Practical 20. Calculate the perimeter of a circle.
Program: -
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