Practical-File-Sample

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

PRACTICAL FILE

OF
ARTIFICIAL INTELLIGENCE (417)
SESSION 2021-22
BY :
NAME- BHUMIKA KAUSHIK
ROLL NO-12102214
UNDER GUIDANCE OF
MR. JAY KUMAR BHAGWANI
FOR PARTIAL FULFILMENT OF
CLASS-X
SUBMITTED TO-

BAL BHARATI PUBLIC SCHOOL, NTPC SIPAT, BILASPUR CERTIFICATE

It is to certify Bhumika Kaushik of class X 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 X examination.

Mr.JAY BHAGWANI MR.SHALABH NIGAM

Internal Examiner External Examiner Principal

ACKNOWLEDGEMENT
I am greatly indebted to my Teacher Mr. Jay Kumar Bhagwani
for his 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 sir Mr. Shalabh Nigam
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

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.# Create a list of following elements : Apple, banana, pineapple, orange

Give the command for the following :

●Add a new element – Guava

fruitlist=["Apple","Banana","Pineapple","Orange"]

fruitlist.append("Guava")
print(fruitlist)

OUTPUT

['Apple', 'Banana', 'Pineapple', 'Orange', 'Guava']

●Insert a new element at specific position eg. in second position

fruitlist=["Apple","Banana","Pineapple","Orange"]

fruitlist.insert(1,"Mango")

print(fruitlist)

OUTPUT

['Apple', 'Mango', 'Banana', 'Pineapple', 'Orange']

●Delete the last element.

fruitlist=["Apple","Banana","Pineapple","Orange"]

fruitlist.pop()

print(fruitlist)

OUTPUT

['Apple', 'Banana', 'Pineapple']

●Sort the list

fruitlist=["Orange","Banana","Pineapple","Apple"]

fruitlist.sort()

print(fruitlist)

OUTPUT

['Apple', 'Banana', 'Orange', 'Pineapple']

12.# Create a tuple and write the commands associated with tuple.

(i) colours=("red","black","blue","green","yellow","pink")

print(colours)

OUTPUT-

('red', 'black', 'blue', 'green', 'yellow', 'pink')


(ii) colours=("red","black","blue","green","yellow","pink")

print(len(colours))

OUTPUT-

(iii) colours=("red","black","blue","green","yellow","pink")

del(colours)

OUTPUT-

Nothing

(iv) colours=("red","black","blue","green","yellow","pink")

print(type(colours))

OUTPUT-

<class 'tuple'>

13.# Create a dictionary and its commands.

(i) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

print(my_dict)

OUTPUT-

{1: 'maths', 2: 'english', 3: 'sst', 4: 'ai', 5: 'hindi'}


(ii) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

my_dict[6]="science"

print(my_dict)

OUTPUT-

{1: 'maths', 2: 'english', 3: 'sst', 4: 'ai', 5: 'hindi', 6: 'science'}

(iii) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

my_dict.pop(3)

print(my_dict)

OUTPUT-

{1: 'maths', 2: 'english', 4: 'ai', 5: 'hindi'}

(iv) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

del my_dict

OUTPUT-

Nothing

(v) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

print(len(my_dict))

OUTPUT-

(vi) my_dict={1:"maths", 2:"english", 3:"sst", 4:"ai", 5:"hindi"}

print(type(my_dict))

OUTPUT-

<class 'dict'>

14.# Create a set and its operations.

(i) myset={"shyam", 3, "ram", "sita", 4,"ram"}

print(myset)

OUTPUT-

{3, 4, 'shyam', 'sita', 'ram'}


(ii) myset={"shyam", 3, "ram", "sita", 4,"ram"}

myset.add(2)

print(myset)

OUTPUT-

{2, 3, 4, 'ram', 'shyam', 'sita'}

(iii) myset={"shyam", 3, "ram", "sita", 4,"ram"}

myset.remove("ram")

print(myset)

OUTPUT-

{3, 4, 'sita', 'shyam'}

15.# 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

17.# 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

18.# 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

19.# 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

20.# Program to create a report card.

sname=input("Student's Name:")

admNo=input("Admission No.")

fname=input("Father's Name:")

mname=input("Mother's Name:")
gender=input("Gender:")

sclass=input("Class:")

eng=float(input("English marks:"))

hin_sans=float(input("Hindi/Sanskrit marks:"))

maths=float(input("Maths marks:"))

science=float(input("Science marks:"))

ssc=float(input("SSc marks:"))

ai=float(input("AI marks:"))

total=eng+hin_sans+maths+science+ssc+ai

percent=(eng+hin_sans+maths+science+ssc+ai)/6

grade=""

if percent>=90:

grade="Excellent"

elif percent>=75:

grade="Very good"

elif percent>=60:

grade="Good"

elif percent>=45:

grade="Average"

elif percent>=33:

grade="Poor"

else:

grade="Fail"

print("***************************************************************** *********************************")

print("BAL BHARATI PUBLIC SCHOOL, NTPC-SIPAT")

print("CBSE Affiliation No.- 3330083")

print("------------------------------------------------------------------------------------------------------------------------------------------------------------------")

print("Student Name:",sname,"\t","\t","Admi No. ",admNo)

print("Father's Name:",fname,"\t","\t","Gender: ",gender)

print("Mother's Name:",mname,"\t","\t","Class: ",sclass)

print("------------------------------------------------------------------------------------------------------------------------------------------------------------------")

max=100
min=33

print("Subject","\t","Max","\t","Min","\t","Marks Obt.")

print("English","\t",max,"\t",min,"\t",eng)

print("Hindi/Sans",max,"\t",min,"\t",hin_sans)

print("Maths","\t",max,"\t",min,"\t",maths)

print("Science","\t",max,"\t",min,"\t",science)

print("SSc ","\t",max,"\t",min,"\t",ssc)

print("AI ","\t",max,"\t",min,"\t",ai)

print("-----------------------------------------------------------------------------------------------------------------------------------------------------------------")

print("Total Marks:","\t","\t","\t",total)

print("Percentage:","\t","\t","\t",percent)

print("Grade: ","\t","\t","\t",grade)

print("-----------------------------------------------------------------------------------------------------------------------------------------------------------------")

print("Class Teacher's Remarks")

print("\t\t\t\t", "Principal Signature")

OUTPUT

Student's Name:BHUMIKA KAUSHIK

Admission No.181550

Father's Name:MR.DEWENDRA KAUSHIK

Mother's Name:MRS.MITHILESH KAUSHIK

Gender:FEMALE

Class:10th
English marks:96

Hindi/Sanskrit marks:99

Maths marks:100

Science marks:97

SSc marks:94

AI marks:99.5

***************************************************************** *********************************

BAL BHARATI PUBLIC SCHOOL, NTPC-SIPAT

CBSE Affiliation No.- 3330083

------------------------------------------------------------------------------------------------------------------------------------------------------------------

Student Name: BHUMIKA KAUSHIK Admi No. 181550

Father's Name: MR.DEWENDRA KAUSHIK Gender: FEMALE

Mother's Name: MRS.MITHILESH KAUSHIK Class: 10th

------------------------------------------------------------------------------------------------------------------------------------------------------------------

Subject Max Min Marks Obt.

English 100 33 96.0

Hindi/Sans 100 33 99.0

Maths 100 33 100.0

Science 100 33 97.0

SSc 100 33 94.0

AI 100 33 99.5

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Total Marks: 585.5

Percentage: 97.58333333333333

Grade: Excellent

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Class Teacher's Remarks

Principal Signature

You might also like