PYTHON PRACTICAL FILE
(ARTIFICIAL INTELLIGENCE –
CLASS IX, 2025–26)
🔹 Program 1: To print personal information
AIM:
To print personal information like Name, Father’s Name, Class, and School
Name.
ALGORITHM:
1. Start the program.
2. Use multiple print() statements to display each piece of information.
3. Stop.
PROGRAM:
# Program to print personal information
print("Name : Aarav Sharma")
print("Father's Name : Mr. Rakesh Sharma")
print("Class : IX")
print("School Name : Delhi Public School")
OUTPUT:
Name : Aarav Sharma
Father's Name : Mr. Rakesh Sharma
Class : IX
School Name : Delhi Public School
🔹 Program 2: To print a pattern using multiple
print statements
AIM:
To print a simple star pattern using print statements.
ALGORITHM:
1. Start the program.
2. Use five print() statements to print one extra star each time.
3. Stop.
PROGRAM:
print("*")
print("**")
print("***")
print("****")
print("*****")
OUTPUT:
*
**
***
****
*****
🔹 Program 3: To find the square of number 7
AIM:
To calculate and print the square of 7.
ALGORITHM:
1. Take a number (7).
2. Multiply the number by itself.
3. Print the result.
PROGRAM:
num = 7
square = num * num
print("Square of", num, "is", square)
OUTPUT:
Square of 7 is 49
🔹 Program 4: To find the sum of two numbers 15
and 20
AIM:
To find and display the sum of two given numbers.
ALGORITHM:
1. Initialize two variables with numbers.
2. Add both numbers.
3. Display the sum.
PROGRAM:
a = 15
b = 20
sum = a + b
print("Sum of", a, "and", b, "is", sum)
OUTPUT:
Sum of 15 and 20 is 35
🔹 Program 5: To convert kilometers into meters
AIM:
To convert a distance given in kilometers to meters.
ALGORITHM:
1. Input distance in kilometers.
2. Multiply the value by 1000.
3. Print the result.
PROGRAM:
km = float(input("Enter distance in kilometers: "))
meters = km * 1000
print(km, "kilometers =", meters, "meters")
OUTPUT:
Enter distance in kilometers: 5
5.0 kilometers = 5000.0 meters
🔹 Program 6: To print the table of 5 up to five
terms
AIM:
To display the multiplication table of 5 up to 5 terms.
ALGORITHM:
1. Use a for loop from 1 to 5.
2. Multiply each number with 5.
3. Display results in table format.
PROGRAM:
num = 5
for i in range(1, 6):
print(num, "x", i, "=", num * i)
OUTPUT:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
🔹 Program 7: To calculate Simple Interest
AIM:
To calculate simple interest for given values of principal, rate, and time.
ALGORITHM:
1. Assign values to principal, rate, and time.
2. Apply the formula: SI = (P × R × T) / 100
3. Print the result.
PROGRAM:
principal = 2000
rate = 4.5
time = 10
si = (principal * rate * time) / 100
print("Simple Interest =", si)
OUTPUT:
Simple Interest = 900.0
🔹 Program 8: To calculate Area and Perimeter of a
Rectangle
AIM:
To calculate and display the area and perimeter of a rectangle.
ALGORITHM:
1. Input length and breadth.
2. Use formula:
o Area = length × breadth
o Perimeter = 2 × (length + breadth)
3. Print results.
PROGRAM:
length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area =", area)
print("Perimeter =", perimeter)
OUTPUT:
Enter length: 5
Enter breadth: 3
Area = 15.0
Perimeter = 16.0
🔹 Program 9: To calculate Area of a Triangle
AIM:
To calculate area of a triangle using base and height.
ALGORITHM:
1. Input base and height.
2. Apply formula: Area = ½ × base × height.
3. Print the result.
PROGRAM:
base = float(input("Enter base of triangle: "))
height = float(input("Enter height of triangle: "))
area = 0.5 * base * height
print("Area of Triangle =", area)
OUTPUT:
Enter base of triangle: 8
Enter height of triangle: 5
Area of Triangle = 20.0
🔹 Program 10: To calculate Average Marks of 3
Subjects
AIM:
To calculate and print average marks of three subjects.
ALGORITHM:
1. Input marks of 3 subjects.
2. Add them and divide by 3.
3. Display the average.
PROGRAM:
m1 = float(input("Enter marks of Subject 1: "))
m2 = float(input("Enter marks of Subject 2: "))
m3 = float(input("Enter marks of Subject 3: "))
average = (m1 + m2 + m3) / 3
print("Average Marks =", average)
OUTPUT:
Enter marks of Subject 1: 80
Enter marks of Subject 2: 75
Enter marks of Subject 3: 90
Average Marks = 81.67
Program 11: To calculate discounted amount
AIM:
To calculate the amount payable after discount.
ALGORITHM:
1. Input total price and discount percentage.
2. Apply the formula:
Discounted Amount = Price - (Price × Discount / 100)
3. Print the discounted amount.
PROGRAM:
# Program to calculate discounted amount
price = float(input("Enter total amount: "))
discount = float(input("Enter discount percentage: "))
discounted_amount = price - (price * discount / 100)
print("Amount after discount =", discounted_amount)
OUTPUT:
Enter total amount: 1000
Enter discount percentage: 10
Amount after discount = 900.0
🔹 Program 12: To calculate Surface Area and
Volume of a Cuboid
AIM:
To find the surface area and volume of a cuboid.
ALGORITHM:
1. Input length, breadth, and height.
2. Use formulas:
o Surface Area = 2(lb + bh + hl)
o Volume = l × b × h
3. Display results.
PROGRAM:
length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
height = float(input("Enter height: "))
surface_area = 2 * (length * breadth + breadth * height + height * length)
volume = length * breadth * height
print("Surface Area =", surface_area)
print("Volume =", volume)
OUTPUT:
Enter length: 5
Enter breadth: 4
Enter height: 3
Surface Area = 94.0
Volume = 60.0
🔹 Program 13: To perform operations on a list of
children
AIM:
To create and modify a list of children selected for Science Quiz.
ALGORITHM:
1. Create a list of names.
2. Remove “Vikram” from the list.
3. Add “Jay” at the end.
4. Remove the item at 2nd position.
5. Print updated lists at each step.
PROGRAM:
children = ["Arjun", "Sonakshi", "Vikram", "Sandhya", "Sonal", "Isha", "Kartik"]
print("Original List:", children)
[Link]("Vikram")
print("After removing Vikram:", children)
[Link]("Jay")
print("After adding Jay:", children)
del children[1]
print("After removing 2nd position item:", children)
OUTPUT:
Original List: ['Arjun', 'Sonakshi', 'Vikram', 'Sandhya', 'Sonal', 'Isha', 'Kartik']
After removing Vikram: ['Arjun', 'Sonakshi', 'Sandhya', 'Sonal', 'Isha', 'Kartik']
After adding Jay: ['Arjun', 'Sonakshi', 'Sandhya', 'Sonal', 'Isha', 'Kartik', 'Jay']
After removing 2nd position item: ['Arjun', 'Sandhya', 'Sonal', 'Isha', 'Kartik', 'Jay']
🔹 Program 14: To perform list operations on a
numeric list
AIM:
To perform slicing and indexing on a list of numbers.
ALGORITHM:
1. Create list num = [23,12,5,9,65,44].
2. Find its length using len().
3. Display elements from 2nd to 4th position.
4. Display elements from 3rd to 5th position using negative indexing.
PROGRAM:
num = [23, 12, 5, 9, 65, 44]
print("Length of list =", len(num))
print("Elements from 2nd to 4th position:", num[1:4])
print("Elements from 3rd to 5th position using negative indexing:", num[-4:-1])
OUTPUT:
Length of list = 6
Elements from 2nd to 4th position: [12, 5, 9]
Elements from 3rd to 5th position using negative indexing: [5, 9, 65]
🔹 Program 15: To create list of first 10 even
numbers and add 1 to each
AIM:
To create a list of first 10 even numbers and add 1 to each element.
ALGORITHM:
1. Create list of first 10 even numbers.
2. Add 1 to each number using a loop.
3. Display the final list.
PROGRAM:
even = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
new_list = []
for i in even:
new_list.append(i + 1)
print("Original List:", even)
print("New List after adding 1:", new_list)
OUTPUT:
Original List: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
New List after adding 1: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
🔹 Program 16: To extend and sort a list
AIM:
To add elements in a list using extend() function and sort it.
ALGORITHM:
1. Create list [10,20,30,40].
2. Extend it with another list [14,15,12].
3. Sort in ascending order.
4. Print final list.
PROGRAM:
List_1 = [10, 20, 30, 40]
List_1.extend([14, 15, 12])
List_1.sort()
print("Final sorted list:", List_1)
OUTPUT:
Final sorted list: [10, 12, 14, 15, 20, 30, 40]
🔹 Program 17: To check if a person can vote
AIM:
To check whether a person is eligible to vote or not.
ALGORITHM:
1. Input age of person.
2. If age ≥ 18 → Eligible.
3. Else → Not eligible.
4. Display result.
PROGRAM:
age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
OUTPUT:
Enter your age: 16
You are not eligible to vote.
🔹 Program 18: To check grade of a student
AIM:
To determine student’s grade based on marks.
ALGORITHM:
1. Input marks.
2. Use conditions:
o ≥90 → A
o 75–89 → B
o 60–74 → C
o 40–59 → D
o <40 → F
3. Print grade.
PROGRAM:
marks = float(input("Enter marks: "))
if marks >= 90:
print("Grade: A")
elif marks >= 75:
print("Grade: B")
elif marks >= 60:
print("Grade: C")
elif marks >= 40:
print("Grade: D")
else:
print("Grade: F")
OUTPUT:
Enter marks: 82
Grade: B
🔹 Program 19: To check if a number is positive,
negative or zero
AIM:
To check whether a number entered by user is positive, negative, or zero.
ALGORITHM:
1. Input a number.
2. Use if–elif–else to compare with 0.
3. Display message accordingly.
PROGRAM:
num = float(input("Enter a number: "))
if num > 0:
print("Number is Positive")
elif num < 0:
print("Number is Negative")
else:
print("Number is Zero")
OUTPUT:
Enter a number: -5
Number is Negative
🔹 Program 20: To print first 10 natural numbers
AIM:
To print first 10 natural numbers using loop.
ALGORITHM:
1. Use for loop from 1 to 10.
2. Print each number.
PROGRAM:
for i in range(1, 11):
print(i)
OUTPUT:
1
2
3
4
5
6
7
8
9
10
🔹 Program 21: To print first 10 even numbers
AIM:
To print first 10 even numbers using loop.
ALGORITHM:
1. Use range starting from 2, step 2, till 20.
2. Print each value.
PROGRAM:
for i in range(2, 21, 2):
print(i)
OUTPUT:
2
4
6
8
10
12
14
16
18
20
🔹 Program 22: To print odd numbers from 1 to n
AIM:
To print all odd numbers up to a limit n.
ALGORITHM:
1. Input n.
2. Use for loop from 1 to n.
3. Use condition if i % 2 != 0.
4. Print odd numbers.
PROGRAM:
n = int(input("Enter the limit: "))
for i in range(1, n + 1):
if i % 2 != 0:
print(i)
OUTPUT:
Enter the limit: 10
1
3
5
7
9
🔹 Program 23: To print sum of first 10 natural
numbers
AIM:
To find sum of first 10 natural numbers.
ALGORITHM:
1. Initialize sum = 0.
2. Run loop from 1 to 10 and add each number.
3. Display total sum.
PROGRAM:
sum = 0
for i in range(1, 11):
sum = sum + i
print("Sum of first 10 natural numbers =", sum)
OUTPUT:
Sum of first 10 natural numbers = 55
🔹 Program 24: To find the sum of all numbers
stored in a list
AIM:
To calculate the total of all numbers stored in a list.
ALGORITHM:
1. Create a list of numbers.
2. Initialize variable total = 0.
3. Use for loop to add each element to total.
4. Display sum.
PROGRAM:
numbers = [3, 7, 2, 9, 5]
total = 0
for num in numbers:
total = total + num
print("Sum of all numbers in the list =", total)
OUTPUT:
Sum of all numbers in the list = 26