Practical File
Practical File
Delhi
ARTIFICIAL
INTELLIGENCE (417)
Class-X
PRACTICAL RECORD
2024-25
Submitted to: Submitted by:
Mridul Pilani Bhavay Gupta
1
CERTIFICATE
This is to certify that this practical work is submitted by
_______________________
Mr. Mridul Pilani
PP INTERNATIONAL SCHOOL
2
INDEX
S. Program Page
No. No.
1. Write a Python program to find largest among three numbers. 4
2. Write a Python program to perform arithmetic calculation. This program 5
accepts two operands and an operator then displays the calculated result.
3. Write a Python program to check whether a given year is Leap year or not. 6
3
1. Write a Python program to find largest among three numbers.
a = int(input("Enter A: "))
b = int(input("Enter B: "))
c = int(input("Enter C: "))
if a > b and a>c:
g=a
elif b>a and b>c:
g=b
elif c>a and c>b:
g=c
print("Greater = ", g)
OUTPUT:
4
2. Write a Python program to perform arithmetic calculation. This
program accepts two operands and an operator then displays the
calculated result.
a= float(input("Enter first operand: "))
b= input("Enter operator(+,-,*,/): ")
c= float(input("Enter second operand: "))
if b=="+":
Result= a+c
elif b=="-":
Result= a-c
elif b=="*":
Result= a*c
elif b=="/":
Result= a/c
else:
print("Invalid operator given")
print("Result:",Result)
OUTPUT:
5
3. Write a Python program to check whether a given year is leap year
or not.
year = 2000
if year%4==0 :
print("Leap Year")
else:
print("Not a Leap Year")
OUTPUT:
6
4. Write a Python program to print table of a given number.
n=int(input("Enter the number to print the tables for:"))
for i in range(1,11):
print(n,"x",i,"=",n*i)
OUTPUT:
7
5. Write a Python Program to print the sum of first n Natural numbers.
n=int(input("Enter a number: "))
sum1 = 0
while(n > 0):
sum1=sum1+n
n=n-1
print("The sum of first n natural numbers is",sum1)
OUTPUT:
8
6. Write a program to calculate mean, median and mode using NumPy
of the following list of distance travelled by a car in a week:
(95,90,49,71,90,100,55]
import statistics
d = [95, 90, 49,71,90,100,55]
m1 = statistics.mean(d)
m2 = statistics.median(d)
m3 = statistics.mode(d)
print ("The mean is: ", m1)
print ("The median is: ", m2)
print ("The mode is: ", m3)
Output:
9
7. Using NumPy package: Create an array of 5 marks and display the
average of all marks.
import numpy as np
import statistics
a = np. array( [95, 90,49,71,80] )
m = statistics.mean(a)
print ("The average is: ", m)
Output:
10
8. Create a list of number of voting done in 6 areas and calculate using
statistics module:
Standard deviation
Variance
import statistics
votes = [59, 52, 49, 71, 44, 63]
std_dev = statistics.stdev(votes)
print("The standard deviation is:", std_dev)
variance = statistics.variance(votes)
print ("The variance is:", variance)
Output:
11
9. Write a program to display a scatter chart for the following points
(2,5), (9,10), (8,3), (5,7), (6,18).
Output:
12
10. Using Matplotlib and the given data, plot a bar chart:
No of people voted = [23,45,31,40,35], Area covered=
['al'"'a2''а3',a4''а5']
import matplotlib.pyplot as plt
a = [23,45, 31,40, 35]
plt. bar (['al', 'a2', 'a3', 'a4', 'a5'], a)
plt.title ('Bar Chart')
plt.xlabel ( 'Area covered')
plt. ylabel( 'No of people voted')
plt. show ( )
Output:
13
11. Using Matplotlib and the given data, plot a scatter chart:
Height = [4.5, 5.2,4.1,3.5,5], Weight = [34,41, 45,56,39]
import matplotlib.pyplot as plt
Weight = [34, 41, 45,56,39]
Height = [4.5, 5.2, 4.1, 3.5,5]
plt.scatter(Height, Weight, c='blue')
plt.title('Scatter plot')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show( )
Output:
14
15