SESSION 2024-25
PRACTICAL FILE
Subject-
Submitted by : SUBMITTED TO
Student’s Name- Teacher’s Name-
Class/Sec- Designation-
Signature- Signature-
1|Page
CERTIFICATE
This is to certify that the project titled ……………………………… submitted
by …………………………………… of Class IX - ……….……., B.B.S. SMRITI
VIDYAPEETH- AURAIYA, is a record of original work carried out under my/her
guidance. The project has been prepared as a partial fulfillment of the requirements
for the subject ………………………………………. .
I hereby certify that the work contained in this project file is authentic and has
not been submitted elsewhere for any academic purpose.
Place: ____________________
Date: ____________________
(Signature of the Project Supervisor)
Teacher's Name-
Designation:
2|Page
ACKNOWLEDGEMENT
I am greatly indebted to my Teacher …………………………………………. 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 …………………………………….. and helping me a lot in
completing my work and assignment.
I also give thanks to respected principal ma’am Mrs. RAMNIK KAUR
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.
3|Page
1.- Write a program to calculate the factorial of a number in Python.
n = int(input("Enter the number for which the factorial needs to be calculated: "))
factorial = 1
if n<0:
print ("Factorial cannot be calculated, non-integer input")
elif n==0:
print ("Factorial of the number is 1")
else:
for i in range (1, n+1):
factorial = factorial *i
print ("Factorial of the given number is: ", factorial)
OUTPUT
Enter the number for which the factorial needs to be calculated: 4
Factorial of the given number is: 24
4|Page
2.- Write a program to display the multiplication table in Python.
numb = int(input(" Enter a number : "))
# using the for loop to generate the multiplication tables
print("Table of: ")
for a in range(1,11):
print(numb, 'x', a, '=', numb*a)
OUTPUT
Enter a number : 5
Table of:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
5|Page
3.- Write a program to check if a number is odd or even in Python.
num = int (input ("Enter any number to test whether it is odd or even: "))
if (num % 2) == 0:
print ("The number is even")
else:
print ("The provided number is odd")
OUTPUT
Enter any number to test whether it is odd or even: 10
The number is even
6|Page
4.- Write a program to find the factors of a number in Python.
numb=int(input("Enter any number-"))
facts=[]
for a in range(1,numb+1):
if numb%a==0:
facts.append(a)
print ("Factors of {} = {}".format(numb, facts))
OUTPUT
Enter any number-8
Factors of 8 = [1, 2, 4, 8]
7|Page
5.- Write a program to check leap year in Python.
year = int (input ("Enter any year that is to be checked for leap year: "))
if (year % 4) == 0:
if (year % 1) == 0:
if (year % 4) == 0:
print ("The given year is a leap year")
else:
print ("It is not a leap year")
else:
print ("It is not a leap year")
else:
print ("It is not a leap year")
OUTPUT
Enter any year that is to be checked for leap year: 2025
It is not a leap year
8|Page
6.- Write a program to calculate the area of a triangle in Python.
#area of triangle
p = float(input('Enter the length of first side: '))
q = float(input('Enter the length of second side: '))
r = float(input('Enter the length of final side: '))
# calculate the semi-perimeter
s = (p + q + r)/2
# calculate the area
area_tri = (s*(s-p)*(s-q)*(s-r)) ** 0.5
print('The area of the triangle is -',area_tri)
OUTPUT
Enter the length of first side: 3
Enter the length of second side: 4
Enter the length of final side: 5
The area of the triangle is - 6.0
9|Page
7.- Write a program to convert Celsius into Fahrenheit in Python.
fahren = float(input("Enter Temperature in Fahrenheit:- "))
celi = (fahren-32)/1.8
print("Equivalent Temperature in Celsius: ", celi)
OUTPUT
Enter Temperature in Fahrenheit: 212
Equivalent Temperature in Celsius: 100.0
10 | P a g e
8.- Write a program to find the square root in Python.
numb = float(input('Enter a number: '))
numsqrt = numb ** 0.5
print('square root of the',numb,'is-',numsqrt)
OUTPUT
Enter a number: 49
square root of the 49.0 is- 7.0
11 | P a g e
9.- Write a program to find the divisibility of a number by another number in Python.
num=int(input("Enter the number whose divisibility needs to be checked: "))
div=int(input("Enter the number with which divisibility needs to be checked:"))
if num%div == 0:
print ("The number is divisible.")
else:
print ("The number is not divisible.")
OUTPUT
Enter the number whose divisibility needs to be checked: 34
Enter the number with which divisibility needs to be checked:12
The number is not divisible.
12 | P a g e
10.- Write a program to find the sum of natural numbers in Python.
n = int(input("Enter any natural number: "))
if n < 0:
print ("Wrong input. Please enter a positive number.")
else:
sum = 0
while (n > 0):
sum +=n
n -=1
print ("The sum of the natural numbers is: ", sum)
OUTPUT
Enter any natural number: 100
The sum of the natural numbers is: 5050
13 | P a g e
11.- Write a program to check if a number is Positive, Negative, or 0 in Python.
n = float (input ("Enter the number: "))
if n > 0:
print ("The number provided is positive")
elif n == 0:
print ("The number input is zero")
else:
print ("The number provided is negative")
OUTPUT
Enter the number: -7
The number provided is negative
14 | P a g e
12.- Write a program to print all prime numbers in an interval in Python.
lwr = int(input("Enter the lowest number"))
upr = int(input("Enter the highest number"))
print("Prime numbers between", lwr, "and", upr, "are:")
for numb in range(lwr, upr + 1):
if numb > 1:
for a in range(2, numb):
if (numb % a) == 0:
break
else:
print(numb)
OUTPUT
Enter the lowest number500
Enter the highest number600
Prime numbers between 500 and 600 are:
503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
15 | P a g e
13.- Write a program to calculate the average of numbers in a given list in Python.
given_list = [8, 9, 1, 23, 15, 20, 19, 13, 8, 7, 5, 2, 7, 10, 14, 16]
sumOfList = 0
# Traverse the given list using for loop
for eleme in given_list:
sumOfList = sumOfList+eleme
# calculating the length of given list using len() function
length = len(given_list)
# Calculate the average value of the given list by Dividing sumOfList with length
listAvg = sumOfList/length
print("The average value of the given list", given_list, "=", listAvg)
OUTPUT
The average value of the given list [8, 9, 1, 23, 15, 20, 19, 13, 8, 7, 5, 2, 7, 10, 14, 16]
= 11.0625
16 | P a g e
14.- Write a program to take in the marks of 5 Subjects and display the grade in Python.
Eng = float(input("Enter the English marks:-"))
Hindi = float(input("Enter the Hindi marks:-"))
Sci = float(input("Enter the Science marks:-"))
SSt = float(input("Enter the S.St. marks:-"))
Maths = float(input("Enter the Maths marks:-"))
AI= float(input("Enter the Artificial intelligence marks:-"))
summarks = Eng+Hindi+Sci+SSt+Maths+AI
avgmark = summarks/5
if(avgmark >= 90):
print("Average of 5 subjects marks =", avgmark, 'Grade =A')
elif(avgmark >= 80 and avgmark < 90):
print("Average of 5 subjects marks =", avgmark, 'Grade =B')
elif(avgmark >= 70 and avgmark < 80):
print("Average of 5 subjects marks =", avgmark, 'Grade =C')
elif(avgmark >= 60 and avgmark < 70):
print("Average of 5 subjects marks =", avgmark, 'Grade =D')
else:
print("Average of All subjects marks =", avgmark, 'Grade =E')
OUTPUT
Enter the English marks:-58
Enter the Hindi marks:-98
Enter the Science marks:-78
Enter the S.St. marks:-88
Enter the Maths marks:-75
Enter the Artificial intelligence marks:-96
Average of All subjects marks = 98.6 Grade =A
17 | P a g e
15.- Write a program to implement Rock, Paper and Scissor game in Python.
import random
print('Winning rules of the game ROCK PAPER SCISSORS are:\n'
+ "Rock vs Paper -> Paper wins \n"
+ "Rock vs Scissors -> Rock wins \n"
+ "Paper vs Scissors -> Scissors wins \n")
while True:
print("Enter your choice \n 1 - Rock \n 2 - Paper \n 3 - Scissors \n")
choice = int(input("Enter your choice: "))
# Looping until user enters valid input
while choice > 3 or choice < 1:
choice = int(input('Enter a valid choice please : '))
# Initialize value of choice_name variable corresponding to the choice value
if choice == 1:
choice_name = 'Rock'
elif choice == 2:
choice_name = 'Paper'
else:
choice_name = 'Scissors'
# Print user choice
print('User choice is:', choice_name)
print("Now it's Computer's Turn...")
18 | P a g e
# Computer chooses randomly any number among 1, 2, and 3
comp_choice = random.randint(1, 3)
# Initialize value of comp_choice_name variable corresponding to the choice value
if comp_choice == 1:
comp_choice_name = 'Rock'
elif comp_choice == 2:
comp_choice_name = 'Paper'
else:
comp_choice_name = 'Scissors'
print("Computer choice is:", comp_choice_name)
print(choice_name, 'vs', comp_choice_name)
# Determine the winner
if choice == comp_choice:
result = "DRAW"
elif (choice == 1 and comp_choice == 2) or (comp_choice == 1 and choice == 2):
result = 'Paper'
elif (choice == 1 and comp_choice == 3) or (comp_choice == 1 and choice == 3):
result = 'Rock'
elif (choice == 2 and comp_choice == 3) or (comp_choice == 2 and choice == 3):
result = 'Scissors'
if result == "DRAW":
print("<== It's a tie! ==>")
19 | P a g e
elif result == choice_name:
print("<== User wins! ==>")
else:
print("<== Computer wins! ==>")
print("Do you want to play again? (Y/N)")
ans = input().lower()
if ans == 'n':
break
print("Thanks for playing!")
OUTPUT
Winning rules of the game ROCK PAPER SCISSORS are:
Rock vs Paper -> Paper wins
Rock vs Scissors -> Rock wins
Paper vs Scissors -> Scissors wins
Enter your choice
1 - Rock 2 - Paper 3 - Scissors
Enter your choice: 1
User choice is: Rock
Now it's Computer's Turn...
Computer choice is: Paper
Rock vs Paper
<== Computer wins! ==>
Do you want to play again? (Y/N): N
Thanks for playing!
20 | P a g e