Practical File IX
Practical File IX
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
guidance. The project has been prepared as a partial fulfillment of the requirements
I hereby certify that the work contained in this project file is authentic and has
Place: ____________________
Date: ____________________
Teacher's Name-
Designation:
2|Page
ACKNOWLEDGEMENT
I am greatly indebted to my Teacher …………………………………………. for
completed.
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:
elif n==0:
else:
factorial = factorial *i
OUTPUT
4|Page
2.- Write a program to display the multiplication table in Python.
for a in range(1,11):
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:
else:
OUTPUT
6|Page
4.- Write a program to find the factors of a number in Python.
facts=[]
for a in range(1,numb+1):
if numb%a==0:
facts.append(a)
OUTPUT
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:
else:
else:
else:
OUTPUT
8|Page
6.- Write a program to calculate the area of a triangle in Python.
#area of triangle
s = (p + q + r)/2
OUTPUT
celi = (fahren-32)/1.8
OUTPUT
10 | P a g e
8.- Write a program to find the square root in Python.
OUTPUT
Enter a number: 49
11 | P a g e
9.- Write a program to find the divisibility of a number by another number in Python.
if num%div == 0:
else:
OUTPUT
12 | P a g e
10.- Write a program to find the sum of natural numbers in Python.
if n < 0:
else:
sum = 0
sum +=n
n -=1
OUTPUT
13 | P a g e
11.- Write a program to check if a number is Positive, Negative, or 0 in Python.
if n > 0:
elif n == 0:
else:
OUTPUT
14 | P a g e
12.- Write a program to print all prime numbers in an interval in Python.
if numb > 1:
if (numb % a) == 0:
break
else:
print(numb)
OUTPUT
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
sumOfList = sumOfList+eleme
length = len(given_list)
# Calculate the average value of the given list by Dividing sumOfList with length
listAvg = sumOfList/length
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.
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
while True:
if choice == 1:
choice_name = 'Rock'
elif choice == 2:
choice_name = 'Paper'
else:
choice_name = 'Scissors'
comp_choice = random.randint(1, 3)
if comp_choice == 1:
comp_choice_name = 'Rock'
elif comp_choice == 2:
comp_choice_name = 'Paper'
else:
comp_choice_name = 'Scissors'
if choice == comp_choice:
result = "DRAW"
result = 'Paper'
result = 'Rock'
result = 'Scissors'
if result == "DRAW":
else:
ans = input().lower()
if ans == 'n':
break
OUTPUT
20 | P a g e