AI Practical File-Manansh
AI Practical File-Manansh
SESSION - 2024-25
ARTIFICIAL INTELLIGENCE
PRACTICAL FILE
(Code – 417)
SUBMITTED TO : SUBMITTED BY :
10th-J
Roll No-18
ACKNOWLEDGEMENT
2. ACKNOWLEDGEMENT (ii)
3. PYTHON 1 - 15
PYTHON
1. Write a program to input the age of an individual and check if he is eligible to vote or not.
if a >= 18:
else:
Output:
2. Write a program to find the maximum number out of the given three numbers
largest = a
largest = b
else:
largest = c
return largest
a = 10
b = 14
c = 12
print(maximum(a, b, c))
Output:
3.Write a program to print the following series:
(a.)5,10,15,20,25
Output:
(b.) 1,4,9,16,25
Output:
4.Write a program to input a number from the user and calculate the factorial of the number.
factorial = 1
factorial *= I
Output:
5.Write a program to print the Fibonacci series: 0,1, 1, 2, 3, 5, 8, 13.
def fibonacci_series(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
n =8
fibonacci_series(n)
Output:
6. Write a program to check if a year is a leap year or not.
y = int (input (“Enter any year that is to be checked for leap year: “))
if (y % 4) == 0:
else:
Output:
7.Write a program in Python to display the multiplication table of a number.
counter = 1
counter += 1
Output:
8. Write a program to input a number and check if it is odd or not.
if x % 5== 0:
else:
Output:
9.Write a program to check if a number is positive, negative or zero.
if n > 0:
elif n < 0:
else:
Output:
10.Write a program in python to input a number from the user and print it’s reverse.
def reverse_number(num):
return int(str(num)[::-1])
reversed_num = reverse_number(number)
Output:
11. Write a program to calculate mean, median and mode (using Numpy library) for the marks
obtained by 10 students (out of 100).
(a. )MEAN:-
import statistics
marks=[90,91,97,93,85,82,94,88,79,92]
m=statistics.mean(marks)
Output:
(b. )MEDIAN:-
import statistics
marks=[90,91,97,94,86,83,93,89,80,98]
m=statistics.median(marks)
Output:
(c. )MODE:-
import statistics
marks=[92,93,100,96,88,85,95,91,82,100]
m=statistics.mode(marks)
Output:
12.Write a program to calculate the Standard Deviation and Variance (using Numpy library) of the
height of 5 dogs (in millimeters). Their heights are: 600mm, 470mm, 170mm, 430mm and 300mm.
import statistics
marks=[600,470,170,430,300]
m=statistics.stdev(marks)
print("the Standar Deviation of the heights of the dogs (in mm) is:",round(m,2))
Output:
(b. ) VARIANCE:-
import statistics
marks=[600,470,170,430,300]
m=statistics.variance(marks)
Output:
13. Create a bar graph to illustrate the distribution of students from various schools who attended a
seminar on “Deep Learning”. The total number of students from each school is provided below.
Oxford School - 50
Sanskriti School - 35
marks=[150,50,65,35,85]
plt.bar(["DPS Lko","Oxf.School","St.Steph","Sanskriti","KPS"],marks)
plt.title('Bar Chart')
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.show()
Output:
14.Write a program to represent the data on the ratings of mobile games on scatter chart. The sample
data is given as:
Games:
Pubg- 4.5
FreeFire- 4.8
MineCraft-4.7
GTA-V-4.6,
FIFA 22-4.3
marks1=[4.5,4.8,4.7,4.6,4.1,4.3]
marks2=["PUBG","FREE-FIRE","MINECRAFT","GTA-V","COD","FIFA 22"]
plt.scatter(marks1,marks2,c='blue')
plt.title('Scatter Plot')
plt.xlabel('RATINGS')
plt.ylabel('GAMES')
plt.show()
Output:
15.Observe the given data for monthly sales of one of the salesmen for 6 months. Plot them on the line
chart. Month Sales
January 2000
February 2500
March 2100
April 2700
May 3000
June 3500
import numpy as np
x = np.array([2000,2500,2100,2700,3000,3500])
y = (["January","February","March","April","May","June"])
plt.plot(x, y)
plt.xlabel("SALES")
plt.ylabel("MONTHS")
plt.title("Line Chart")
plt.show()
Output: