Class XII Computer Science HHW Project

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Class XII Computer Science HHW Project (2024-25)

n1 = int(input('Enter number of values to store in list-1: '))


L1 = []
for i in range(n1):
x = int(input('Enter an integer value: '))
L1.append(x)

n2 = int(input('Enter number of values to store in list-2: '))


L2 = []
for i in range(n2):
x = int(input('Enter an integer value: '))
L2.append(x)

n3 = int(input('Enter number of values to store in list-3: '))


L3 = []
for i in range(n3):
x = int(input('Enter an integer value: '))
L3.append(x)

L4 = []
for i in range(n1):
fact = 1
x = L1[i]
for j in range(1, x+1):
fact *= j
L4.append(fact)

L5 = []
for i in range(n2):
fact = 1
x = L2[i]
for j in range(1, x+1):
fact *= j
L5.append(fact//(i+1))

L6 = []
for i in range(n3):
fact = 1
x = L3[i]
for j in range(1, x+1):
fact *= j
L6.append(int(fact**0.5))

Sum1 = 0
for i in range(n1):
Sum1 += L4[i]*2//(i+1)

Sum2 = 0
for i in range(n2):
Sum2 += L5[i]*2//(i+1)

Sum3 = 0
for i in range(n3):
Sum3 += L6[i]*2//(i+1)

L7 = [Sum1+Sum2, Sum2+Sum3, Sum3+Sum1]


Sum4 = 0
n4 = len(L7)
for i in range(n4):
Sum4 += L7[i]*2//(i+1)
Avg1 = Sum4/n4
L8 = []
for i in range(n4):
L8.append((L7[i]-Avg1)**2)

L9 = [Sum1-Sum2, Sum2-Sum3, Sum3-Sum1]


Sum5 = 0
n5 = len(L9)
for i in range(n5):
Sum5 += L9[i]*2//(i+1)

Avg2 = Sum5/n5
L10 = []
for i in range(n4):
L10.append((L9[i]-Avg2)**2)

Sum6 = 0
for i in range(n4):
Sum6 += L8[i]

Sum7 = 0
for i in range(n5):
Sum7 += L10[i]

sd1 = (Sum6/n4)**0.5
sd2 = (Sum7/n5)**0.5

v1 = int(sd1)
v2 = int(sd2)

print(sd1, sd2)

***************************************************************************************
Inspect the program shown above carefully. It contains a lot of repetitive code. Try to
make the program more compact by converting various repetitive code into user
defined functions and then use those functions to carry out the required calculations
and get the same output.
A sample run of the above program is given below. You can test run your own modified
program containing functions using the same data.
General Instructions
• The project should be handwritten in A4 size paper. Write the modified program
NEATLY. You may use multi-colored pen for the same.
• Write your name, class, section, session, and subject at the top of the first page
• Staple the pages and submit the stapled document. No need for a channel file
• Work has to be original and done by the student. Plagiarized contents will not
be assessed

Due Date of Submission: 20.06.2024

You might also like