You are on page 1of 7

Practice Paper Set

Question Paper Class: XII


Session: 2021-22
Computer Science (Code 083)
(Theory: Term-1)
Maximum Marks: 25 Time Allowed: 45 Minutes

Q.N. Section-A

1 Write the output of the following: 1

print(range(0,8,2))
a. 0,2,4,6
b. range(0, 8, 2)
c. Error
d. None of the above
2 Which of the following is not a token? 1

a. //
b. “X”
c. ##
d. 23
3 Which statement is adding remainder of 8 divided by 3 to the product of 5 and 6? 1

a. 8 % 3 + 5 * 6
b. 8/3 + 5 * 6
c. 8 // 3 + 6.5
d. None of the above
4 Write the output of the following: 1
i=9
while True:
if i%3==0:
break
print("A")
a. A
A
b. A
c. Loop will not execute
d. None of the above
5 Write the output of the following 1
for x in range(10,20):
if (x%2==0):
continue
print(x)
a. Error
b. No output
c. Display from 10 to 19
d. None of the above

6 Write the output of the following code : 1

s="blog"
for i in range(-1,-len(s),-1):
print(s[i],end="$")
a. g$o$l$b$
b. g$o$l$
c. Error
d. None of the above

7 Write the output of the following : 1


L = [[5, 7, 9, 1 ], [12, 23, 4, 9]]
for r in L:
r.reverse( )
for e in r:
print(e, end = ” “)
a. 1 9 7 5 9 4 23 12
b.
1975
9 4 23 12
c. Error
d. None of the above

8. Write the output of the following: 1


L = [11, 22, 33, 44, 55, 66]
for i in range(1, 6):
L[i - 1] = L[i]*2
for i in range(0, 4):
print(L[i], end = " ")
a. 44 66 88 110
b. 22 33 44 55
c. 11 22 33 44
d. Error
9. def pow(b, p): 1
y = b ** p
return y
def square(x):
a = pow(x, 2)
return a
n=5
result = square(n)
print(result)
a.5
b. 10
c. 25
d. 32

10. What will be the output of the following Python code? 1

x = 50
def func():
global x
print('x is', x)
x=2
print('Changed global x to', x)
func()
print('Value of x is', x)
a. b.
x is 50 x is 50
Changed global x to 2 Changed global x to 2
Value of x is 2 Value of x is 50

c. d. None of the mentioned


x is 50
Changed global x to 50
Value of x is 50

11. What will be the output of the following Python code? 1

def display(str1):

p=""

for i in range(0,len(str1)):

if(str1[i].islower()):

p=p+str1[i].upper()

elif str1[i].isupper():

p=p+str1[i].lower()
else:

if i%3==0:

p=p+str1[i+1]

else:

m=m+"$"

print(p)
display(“"RlBsChOoLlUcKnOw")
a. rLbScHoOlLuCkNoW
b. rLBScHOOlLUCkNOW
c. Rlbschoollucknow
d. None of these

12. What will be the output of the following Python code? 1

a=10
b=20
def change():
global b
a=45
b=56
change()
print(a)
print(b)

a. 45
56
b. 10
56
c. 10
20
d. Syntax error
13 “Fruitful functions” are functions that must… 1
a. return a value
b. not return a value
c. print something
d. display something on the screen

14 _________ function help us to read the csv file. 1


a. reader( )
b. read( )
c. read(n)
d. readline( )

15 Which of the following options can be used to read the first line of a text file data.txt? 1

a. f = open(‘data.txt’); f.read()
b. f = open(‘data.txt’,’r’); f.read(n)
c. myfile = open(‘data.txt’); f.readline()
d. f = open(‘data.txt’); f.readlines()

16 Let the file pointer is at the end of 3rd line in a text file named “data.txt”. Which of the 1
following option can be used to read all the remaining lines?

a. f.read( )
b. f.read(all)
c. f.readline( )
d. f.readlines( )

17 ____________________ module is used for serializing and de-serializing any Python 1


object structure.

a. pickle
b. unpickle
c. pandas
d. math

18 Which of the following error is returned when we try to open a file in write mode which 1
does not exist?

a. FileNotFoundError
b. FileFoundError
c. FileNotExistError
d. None of the above
19 f.seek(10,0) will move 10 bytes forward from beginning of file.(T/F) 1

a. True
b. False

20. Rohan opened the file “myfile.txt” by using the following syntax. His friend told him few 1
advantages of the given syntax. Help him to identify the correct advantage.

with open ("myfile.txt", "a") as file_object:


a. In case the user forgets to close the file explicitly the file will closed
automatically.
b. file handle will always be present in the beginning of the file even in
append mode.
c. File will be processed faster
d. None of the above

21. Which statement will return error? 1

import pickle
f=open("data.dat",'rb')
d=pickle.load(f)
f.end()
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4

Code:. 1
1

22. Write the output of the First Print statement :

a. Hello
b. Hell
c. ello
d. None of the above

23. Refer to the above code, Write the output of Second Print Statement 1

a. om
b. me
c. co
d. None of the above

24. Refer to the above code ,: Write the output of Third Print Statement 1

a. e to m
b. e to my
c. to my
d. None of the above

25. Refer to the above code , Write the output of Fourth Print Statement 1

a. 17
b. 16
c. 19
d. 18

MADE BY:- SHWETA KULSHRESTHA PGT RLB, CHINHAT

You might also like