Class 12 Computer Science Unit Test Paper

Unit Test – I ( 2021-22)

Q.1  a) Name the Python Library modules which need to be imported to invoke the following functions :- (1)

i) sqrt

ii) random

b) Rewrite the following code in python after removing all syntax error(s). Underline each corrections done in the code. (2)

 

250 = Number
WHILE Number <=1000:
    If Number=>750:
        print Number
        Number =Number+100
    elseif:
        print Number * 2
        Number = + 50

Answer:

Number =250
while Number <=1000:
     if Number <=750:
       print (Number)
       Number = Number+100
     else:
        print (Number * 2)
        Number = + 50

 

c) Find and write the output of the following python code : (2 x 2 = 4)
i)

M1='CoMpUTER'
M2='BUgS'
M3=''
for I in range (0,len(M2)+1):
    if M1[I]>='A' and M1<='M':
        M3=M3+M1[I]
    elif M1[I]>='N' and M1<='Z':
        M3=M3+M2[I]
    else:
        M3=M3+'*'
print (M3)

 

Answer:

CoMpU

ii)

def Changer(P,Q=10):
    P=P/Q
    Q=P%Q
    print (P,'#',Q)
    return P
A=250
B=25
A=Changer(A,B)
print (A,"$",B)
B=Changer(B)
print (A,"$",B)
A=Changer(A)
print (A,'$',B)

 

Answer:

10.0 # 10.0
10.0 $ 25
2.5 # 2.5
10.0 $ 2.5
1.0 # 1.0
1.0 $ 2.5

d) How many times will the following for loop execute and what’s the output ? (1)

Numbers = [9, 18, 27, 36]
for Num in Numbers:
    for N in range (1, Num%8):
        print (N,"#", end="")
print()

 

Answer:

1 #1 #2 #1 #2 #3 #

Q. 2 Write the functions for the following :- (3 x 2 = 6)

a) Swapper(Numbers) to swap the first half of the contents of a list Numbers with second half of the content of list Numbers and display the swapped values.
For example:
Numbers=[35,67,89,23,12,45]
After swapping [23,12,45,35,67,89]

b) How Many(ID,Val) to count and display number of times the value Val is present in the list ID.
For example:
ID contains [45,65,78,45,23,12,45] and Val contains 45
The function should display
45 found 3 times

c) Count 3 and 7 (N) to find and display the count of all those numbers which are between 1 and N, which are either divisible by 3 or by 7.
For example:
If the value of N is 15
The sum is 7
As (3,6,7,9,12,14,15 in between 1 to 15 either divisible of 3 or 7)

 

Q. 3 Answer the following :- (2 x 3=6)

a) Write the names of any four data types available in Python.

b) What is the difference between formal parameters and actual parameters? What are there alternative names ? Also give a suitable python code to illustrate both.

c) What is the difference between a local variable and a global variable ? Also, give a suitable code to illustrate both.

By cbsepython

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.

Leave a Reply

Your email address will not be published. Required fields are marked *