~1~
ST. VINCENT PALLOTTI SCHOOL
Practical File
On
Artificial Intelligence
(417)
Class X
Session: 2024 - 2025
Std. 10th - AI (Rohan Sir) Practical File
~2~
INDEX
Sr. Page Teacher’s
Assignments
No. no. Signature
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
Std. 10th - AI (Rohan Sir) Practical File
~3~
Practical - 1: Write a program in Python to calculate the surface area and volume of a cuboid.
Code:
length = float(input("Enter length: "))
width= float(input("Enter width: "))
height= float(input("Enter height: "))
surface_area=2*(length * width + length * height + width * height)
volume = length * width * height
print("Surface area:", surface_area)
print("Volume:", volume)
output:
Enter length: 20
Enter width: 14
Enter height: 10
Surface area: 1240.0
Volume: 2800.0
Practical - 2: Write a program in Python to ask for height in centimeters and convert it into feet and inches.
Code:
# Ask the user for height in centimeters
cm = float(input("Enter your height in centimeters: "))
inches = cm / 2.54 # Convert to inches (1 inch = 2.54 cm)
feet = int(inches // 12) # Convert to feet and remaining inches
remaining_inches = round(inches % 12, 2)
# Display the result
print("Your height is",feet,"feet and", remaining_inches, "inches.")
output:
Enter your height in centimeters: 162
Your height is 5 feet and 3.78 inches.
Practical - 3: Write a program in Python to check whether the given number is even or odd.
Code:
num=int(input("Enter a number: "))
if((num%2)== 0):
print("It is an even number.")
else:
print("It is an odd number.")
output:
Enter a number: 2
It is an even number.
Enter a number: 3
It is an odd number.
Std. 10th - AI (Rohan Sir) Practical File
~4~
Practical - 4: Write a program in Python to check whether the applicant is eligible to vote in the elections
or not.
Code:
age = int(input("Enter your age: "))
if age < 18:
print("You are not eligible to vote.")
elif age > 18:
print("This is your first time voting. Make it count!")
else:
print("You are eligible to vote.")
output:
Enter your age: 16
You are not eligible to vote.
Enter your age: 18
You are eligible to vote.
Enter your age: 19
This is your first time voting. Make it count!
Practical - 5: Write a program in Python to find the sum of all numbers stored in a list.
Code:
numbers=[6, 5, 3, 8, 4, 2, 5, 4, 11]
sum=0
for i in numbers:
sum=sum + i
print("Sum is:", sum)
Output: Sum is: 48
Practical - 6: Write a program in Python to print 4, 3, 2, 1, 0 using while loop.
Code:
count=4
while count>=0:
print(count)
count-=1
output:
4
3
2
1
0
Practical - 7: Write a program in Python to add numbers through a function.
Code:
def calcsum(x,y):
s=x+y
return s
num1=float(input("Enter first number:"))
num2=float(input("Enter second number:"))
sum=calcsum(num1,num2)
print("Sum of two given numbers is", sum)
output:
Enter first number:3
Enter second number:7
Sum of two given numbers is 10.0
Std. 10th - AI (Rohan Sir) Practical File
~5~
Practical - 8: Write a program in Python to count the number of vowels present in a text file.
[Data inside the given text file: Video provides a powerful way to help you prove your point.]
Code:
file_in=open("D:\\[Link]","r")
str=file_in.read( )
count=0
for i in str:
if i=='a' or i=='e' or i=='i' or i=='o' or i=='u':
count=count+1
print("Total vowels present in the text file:",count)
output: Total vowels present in the text file: 21
Practical - 9: Write a program in Python to perform the following operations on an array using appropriate
Python libraries. You have an array containing the marks of students in a class test: [45, 55, 55, 44, 78, 90,
60]. [(A.) Addition by 2]
Code:
import numpy as np
#create a NumPy array from the list of marks
marks = [Link]([45, 55, 55, 44, 78, 90, 60])
print("Array before addition:",marks)
#addition by 2 in each
mark_plus = marks+2
print("Array after addition: ")
print("Addition by 2:", mark_plus)
output:
Array before addition: [45 55 55 44 78 90 60]
Array after addition:
Addition by 2: [47 57 57 46 80 92 62]
Practical 10- Write a program in Python to perform the following operations on an array using appropriate
Python libraries. You have an array containing the marks of students in a class test: [45, 55, 55, 44, 78, 90,
60]. [(B.) Floor division with 5]
Code:
import numpy as np
# Create a NumPy array from the list of marks
marks = [Link]([45, 55, 55, 44, 78, 90, 60])
#Floor division with 5
marks_divided = marks // 5
print("Array after floor division:")
print("Floor division with 5:", marks_divided)
output:
Array after floor division:
Floor division with 5: [ 9 11 11 8 15 18 12]
Practical 11- Write a Python program that computes the mean, median, mode, and standard deviation
from the array of student marks in a class test: [45, 55, 55, 44, 78, 90, 60].
Code:
import numpy as np
# Create a NumPy array from the List of marks
marks = [Link]([45, 55, 55, 44, 78, 90, 60])
# Find the mean, median, mode, and standard deviation
mean = [Link](marks)
median = [Link](marks)
Std. 10th - AI (Rohan Sir) Practical File
~6~
mode = [Link]([Link](marks))
std_deviation = [Link](marks)
print("Mean, Median, Mode, and Standard Deviation:")
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode)
print("Standard Deviation:", std_deviation)
Output:
Mean, Median, Mode, and Standard Deviation:
Mean: 61.0
Median: 55.0
Mode: 55
Standard Deviation: 15.802350638885525
Practical 12 - Write a program to plot a bar chart in Python to display the results of a school for five
consecutive years.
Code:
import [Link] as chart
year=['2015','2016','2017','2018','2019'] # list of years
pass_percentage=[98.50,70.25,55.20,90.5,61.50] #list of pass percentage
bar_colors=['b','g','r','m','c'] # colour code of bar charts
#bar( ) function - to create the bar chart
[Link](year, pass_percentage, width=0.2, color=bar_colors)
[Link]("year") # label for x-axis
[Link]("Pass%") # label for y-axis
[Link]("Results of SVPS for five consecutive years")#chart title
[Link]( ) # function to display bar chart
Output:
Practical 13 - Write a program in Python to plot a pie chart on water consumption in daily life.
Code:
import [Link] as pl
consumption=[5,30,50,3]
[Link](consumption, labels=["Drinking","Bathing","Washing
clothes","Cooking"], autopct= ' %1.1f%% ' )
[Link]("Water Consumption in Daily Life")
[Link]()
output:
Std. 10th - AI (Rohan Sir) Practical File
~7~
Practical 14 - Write a program in Python to load and display an image using OpenCV Library.
Code:
import cv2 Output:
img = [Link]("[Link]")
[Link]("My Image",img)
[Link](0)
[Link]()
Practical 15 - Write a program in Python to load and display an image in GRAYSCALE using OpenCV Library.
Code:
import cv2
# Load the image in grayscale
image = [Link]("[Link]", cv2.IMREAD_GRAYSCALE)
# Display the image
[Link]('Grayscale Image', image)
[Link](0)
[Link]()
Output:
Std. 10th - AI (Rohan Sir) Practical File