0% found this document useful (0 votes)
15 views20 pages

AI Practical File-Manansh

This document is a practical file for the Artificial Intelligence course at Delhi Public School, Kalyanpur for the session 2024-25. It includes various Python programming exercises, such as checking voting eligibility, calculating factorials, and generating series, along with data visualization tasks using libraries like Matplotlib. The file acknowledges the guidance of the subject teacher and contains a structured table of contents.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views20 pages

AI Practical File-Manansh

This document is a practical file for the Artificial Intelligence course at Delhi Public School, Kalyanpur for the session 2024-25. It includes various Python programming exercises, such as checking voting eligibility, calculating factorials, and generating series, along with data visualization tasks using libraries like Matplotlib. The file acknowledges the guidance of the subject teacher and contains a structured table of contents.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DELHI PUBLIC SCHOOL, KALYANPUR

SESSION - 2024-25
ARTIFICIAL INTELLIGENCE
PRACTICAL FILE
(Code – 417)

SUBMITTED TO : SUBMITTED BY :

RATNA MALHOTRA Manansh Singh

10th-J

Roll No-18
ACKNOWLEDGEMENT

I would like to convey my heartfelt thanks to Ms.Ratna Malhotra my faculty of


Artificial Intelligence who gave her valuable guidance for the completion of my
Practical File. She helped me to comprehend important details of the file. My
practical File has been successful only because of her able guidance and support.

Signature of the Subject Teacher Manansh Singh


10th-J
Roll No-18

Signature of the Principal


CONTENTS

S.No. TOPIC PAGE NO.

1. COVER PAGE (i)

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.

a=int(input("Enter your age:"))

if a >= 18:

print("You are eligible to vote.")

else:

print("You are not eligible to vote.")

Output:
2. Write a program to find the maximum number out of the given three numbers

def maximum(a, b, c):

if (a >= b) and (a >= c):

largest = a

elif (b >= a) and (b >= c):

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

for num in range(5,26,5):

print(num, end=' ')

Output:

(b.) 1,4,9,16,25

for num in range(1, 6):

print(num * num, end=' ')

Output:
4.Write a program to input a number from the user and calculate the factorial of the number.

num=int(input("Enter the number whose Factorial is to be calculated:"))

factorial = 1

for i in range(1, num + 1):

factorial *= I

print(f"The factorial of {num} is {factorial}")

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):

print(a, end=' ')

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:

print (“The given year is a leap year”)

else:

print (“It is not a leap year”)

Output:
7.Write a program in Python to display the multiplication table of a number.

m=int(input("Enter the number whose multiplication table is needed:"))

counter = 1

while counter <= 10:

result = counter * multiplier

print(f"{counter} x {multiplier} = {result}")

counter += 1

Output:
8. Write a program to input a number and check if it is odd or not.

x =int(input("Enter the number to be checked whether it's ODD or not:"))

if x % 5== 0:

print(x,"is an Odd Number.")

else:

print(x,"is not an Odd Number.")

Output:
9.Write a program to check if a number is positive, negative or zero.

n=int(input("Enter the number to be checked:"))

if n > 0:

print("The number entered is Positive.")

elif n < 0:

print("The number entered is Negative.")

else:

print("The number entered is equal to zero.")

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])

number = int(input("Enter a number to reverse: "))

reversed_num = reverse_number(number)

print(f"The reverse of {number} is {reversed_num}")

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)

print("The average marks of 10 students is:",round(m,2))

Output:

(b. )MEDIAN:-

import statistics

marks=[90,91,97,94,86,83,93,89,80,98]

m=statistics.median(marks)

print("The middle value of the sorted marks of 10 students is:",m)

Output:

(c. )MODE:-

import statistics

marks=[92,93,100,96,88,85,95,91,82,100]

m=statistics.mode(marks)

print("The most frequent marks out of marks obtained by 10 students is:",m)

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.

(a. )STANDARD DEVIATION:-

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)

print("The Variance of the heights of the dogs (in mm) is:",round(m,2))

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.

DPS Lucknow -150

Oxford School - 50

St. Stephens School- 65

Sanskriti School - 35

Kanpur Public School- 85

import matplotlib.pyplot as plt

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,

Call of duty- 4.1

FIFA 22-4.3

import matplotlib.pyplot as plt

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 matplotlib.pyplot as plt

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:

You might also like