PRACTICAL FILE
OF
ARTIFICIAL INTELLIGENCE (417)
SESSION 2022-2023
BY :
NAME: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ROLL NO: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
UNDER GUIDANCE OF
MR. Vinay Mathur and Devendra Singh Chouhan
FOR PARTIAL FULFILMENT OF
CLASS-IX
SUBMITTED TO:
Delhi Public School, Jodhpur, Pali Road
CERTIFICATE
It is to certify _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ of class IX has successfully
completed the practical work with the help of Python language under my guidance
and supervision.
I am satisfied with his initiatives and his effort for completion of the practical work.
As a part of curriculum of CBSE class IX examination.
Mr. Vinay Mathur & Devendra Singh Chouhan Ms. Niharika Chopra
Internal Examiner/ External Examiner Principal
ACKNOWLEDGEMENT
I am greatly indebted to my Teachers Mr. Vinay Mathur and
Devendra Singh Chouhan for their effervescent,
encouragement and for constructive guidance. I would like to
express my gratitude to him for making me proficient in
learning and understanding through Python and helping me a
lot in completing my work and assignment.
I also give thanks to respected principal Ms. Niharika Chopra
without whose co-operation this practical work wouldn’t have
been completed.
I am heartedly thankful to my parents, my family and my
classmates who helped me through my work.
1.# Python Program to find Total, Average, and Percentage of Five Subjects
english = float(input("Please enter English Marks: "))
math = float(input("Please enter Math score: "))
computers = float(input("Please enter Computer Marks: "))
physics = float(input("Please enter Physics Marks: "))
chemistry = float(input("Please enter Chemistry Marks: "))
total = english + math + computers + physics + chemistry
average = total / 5
percentage = (total / 500) * 100
print("\nTotal Marks = %.2f" %total)
print("Average Marks = %.2f" %average)
print("Marks Percentage = %.2f" %percentage)
OUTPUT- 1
Please enter English Marks: 85
Please enter Math score: 98
Please enter Computer Marks: 95
Please enter Physics Marks: 92
Please enter Chemistry Marks: 93
Total Marks = 463.00
Average Marks = 92.60
Marks Percentage = 92.60
OUTPUT- 2
Please enter English Marks: 96
Please enter Math score: 99
Please enter Computer Marks: 94
Please enter Physics Marks: 95
Please enter Chemistry Marks: 97
Total Marks = 481.00
Average Marks = 96.20
Marks Percentage = 96.20
2.# Program to convert the currency from rs. To dollar or vice versa.
usd = float(input("Enter currency in USD: "))
inr = usd * 73
print("The currency in INR is",round(inr,2))
&
inr = float(input("Enter currency in inr: "))
usd = inr/73
print("The currency in USD is",round(usd,2))
OUTPUT-1
Enter currency in USD: 3
The currency in INR is 219.
Enter currency in USD: 10
The currency in INR is 730.0
OUTPUT-2
Enter currency in inr: 4
The currency in USD is 0.05
Enter currency in inr: 73
The currency in USD is 1.0
3.# Program to check if entered number is Even or Odd.
num=int(input("Enter any number"))
if (num % 2 != 0):
print("Number is odd")
else:
print("Number is even")
OUTPUT-1
Enter any number4
Number is even
OUTPUT-2
Enter any number5
Number is odd
4.# Program to display the following pattern :
b)1
12
123
rows = int(input("Enter the number of rows: "))
for i in range(1, rows+1):
for j in range(1, i + 1):
print(j, end=' ')
print("")
OUTPUT-1
Enter the number of rows: 5
12
123
1234
12345
OUTPUT-2
Enter the number of rows: 2
12
5.# Program to check if the entered number is prime or not.
for i in range(2,int(num/2)+1):
if(num % i) == 0:
print(num,"is not a prime number")
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")
OUTPUT-1
Enter an input number:17
17 is a prime number
OUTPUT-2
Enter an input number:10
10 is not a prime number
6.# Program to display the table of a given number in the following format :
table=int(input("Enter any number"))
for i in range(1,6):
print(table,"*",i,"=",table*i)
OUTPUT-1
Enter any number4
4*1=4
4*2=8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
OUTPUT-2
Enter any number2
2*1=2
2*2=4
2*3=6
2*4=8
2 * 5 = 10
7.# Program to calculate the grade of students : Marks
> = 90 A1
>=80 A2
>=70 B1
>=60 B2
>=50 C1
>=40 C2
>=33 D
<=33 E
marks=float(input("Enter your marks: "))
if marks >= 90:
print("A1")
elif marks >=80:
print("A2")
elif marks >=70:
print("B1")
elif marks >=60:
print("B2")
elif marks >=50:
print("C1")
elif marks >=40:
print("C2")
elif marks >=33:
print("D")
else:
print("E")
OUTPUT-1
Enter your marks: 85
A2
OUTPUT-2
Enter your marks: 30
E
8.# Program to calculate the factorial of a number
num = int(input("Enter a number: "))
factorial = 1
if num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
OUTPUT-1
Enter a number: 6
The factorial of 6 is 1
The factorial of 6 is 2
The factorial of 6 is 6
The factorial of 6 is 24
The factorial of 6 is 120
The factorial of 6 is 720
OUTPUT-2
Enter a number: 4
The factorial of 4 is 1
The factorial of 4 is 2
The factorial of 4 is 6
The factorial of 4 is 24
9.# Program to calculate the discount Total amount > 10000 (20% ) >5000 (10%)
<5000 (5%)
amount=float(input("Enter total amount: "))
if amount> 10000:
print("Your discount is ",0.4*amount,)
elif amount> 5000:
print("Your discount is ",0.2*amount)
else:
print("Your discount is ",0.1*amount)
OUTPUT-1
Enter total amount: 80
Your discount is 8.0
OUTPUT-2
Enter total amount: 500
Your discount is 50.0
10.# Program to calculate the sum of the series :
a) 1 + 2 + 3 + ………..
b) 2 + 4 + 6 + ……..
c) ½ + ¼ + 1/6 + ……
num=int(input("enter the number for upto which series should go:"))
sum= (num/2)*(2+(num-1))
print("sum of the series is: ", sum)
OUTPUT-1
enter the number for upto which series should go:4
sum of the series is: 10.0
OUTPUT-2
enter the number for upto which series should go:1
sum of the series is: 1.0
11.# Program to find out the largest number out of three numbers.
num1=int(input("Enter first number: "))
num2=int(input("Enter second number: "))
num3=int(input("Enter third number: "))
if num1>(num2 and num3):
print(num1,"is greatest among all")
elif num2>(num1 and num3):
print(num2,"is greatest among all")
elif num3>(num1 and num2):
print(num3,"is greatest among all")
OUTPUT- 1
Enter first number: 10
Enter second number: 4
Enter third number: 99
99 is greatest among all
OUTPUT- 2
Enter first number: 1
Enter second number: 9
Enter third number: 6
9 is greatest among all
12.# Display the Fibonacci series upto nth term.
nterms = int(input("How many terms? "))
n1, n2 = 0, 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
OUTPUT- 1
How many terms? 10
Fibonacci sequence:
13
21
34
13.# Program to find out the length of the string.
string=str(input("Enter any word:"))
print("length of the string is:",len(string))
OUTPUT- 1
Enter any word:Bhumika
length of the string is: 7
OUTPUT- 2
Enter any word:Muskan
length of the string is: 6
14.# Program to find out the sum of digits of a number.
n=int(input("Enter a number:"))
tot=0
while(n>0):
dig=n%10
tot=tot+dig
n=n//10
print("The total sum of digits is:",tot)
OUTPUT- 1
Enter a number:22
The total sum of digits is: 4
OUTPUT- 2
Enter a number:484
The total sum of digits is: 16