Professional Documents
Culture Documents
Kendriya Vidyalaya Sangathan, Lucknow Region
Kendriya Vidyalaya Sangathan, Lucknow Region
Section-A
Q.N. This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option.
1 Find the invalid identifier from the following
a) None b) address c) myVar d) union
2 5. What is the return type of function id() ?
a) bool b) float c) int d) dict
3 Given an object
P= (10, 20, 30, 40, 50, 60, 70, 80, 90)
What will be the output of print(P[-2:-5:-1])
a) (10,20,30) b) (80, 70, 60) c) (60,70,80) d) (90,80,70,60)
4 Which statement is not true about binary file?
a) A binary file contains arbitrary binary data.
b) Binary files store the data in raw bit pattern.
c) Binary files store data in human readable form.
d) In binary files there is no delimiter for a line.
5 Which file mode will allow write operation in binary file?
a) rb b) wb c) w d) r+
6 Assume that the position of the file object fp is at the beginning of 5th line in a text file.
Which of the following options can be used to read all the remaining lines?
a) fp.read(n-5) b) fp.read(n)
c) fp.readline() d) fp.readlines()
7 Which one is the correct statement to open a file to add data at the end of text file
'Poem.txt'?
a) fp=open('Poem.txt','w') b) fp=open('Poem.txt','a')
c) fp=open('Poem.txt','r') d) fp=open('Poem.txt','r+')
8 Consider the following function:
def MyFun( ):
print(2+3)
What will be the return type of MyFun() function?
a) int b) float c) None d) Tuple
9 1. Which of the following functions is a built-in function in python?
a) seed( ) b) sqrt( ) c) factorial( ) d) print( )
Page |1
10 Given an object L= (12,13,14,15) Identify the statement that will result in an error.
a) L.append(16) b) print(L[2])
c) min(L) d) len(L)
11 Which of the following operator is not allowed with string data type?
(a) + (b) * (c) * * (d) in
16 fp=open('calc.txt','w')
x=45
Which statement is correct as third line of this code?
a) fp.write(x) b) fp.read(x)
c) fp.read(45) d) fp.write(str(x))
17
(a) comma (b) semicolon
(c) hyphen (d) colon
18 Which of the following statements is true?
a) pickling creates an object from a sequence of bytes
b) pickling is used for object serialization
c) pickling is used for object deserialization
d) pickling is used to manage all types of files in Python
Page |2
21 Which statement is used to retrieve the current position within the file?
(a) fp.seek( ) (b) fp.tell( ) (c) pf.loc (d) fp.pos
22 What is the output of the following function?
>> complex(1+2j)
a) Error b) 1 c) 2j d) 1+2j
23 What is the output of the code shown below?
>>lst = [1, 2, 3]
>>lst[3]
a) NameError b) ValueError c) IndexError d) TypeError
24 Which of the following method is not related with binary file?
a) dump( ) b) load( ) c) seek( ) d) writerows( )
25 What will be the output of following?
>>> st='missamarri'
>>> st.count('s')==st.count('m')
a) False b) True c) None d) 2
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
26 Suppose list1 is [1, 3, 2] What is list1 * 2?
a) [2, 6, 4]
b) [1, 3, 2] [ 1, 3,2]
c) [1, 3, 2, 1, 3, 2]
d) [1, 3, 2, 3, 2, 1]
a) x is 50 b) x is 50
Changed local x to 2 Changed local x to 2
x is now 2 x is now 50
c) x is 50 d) None of these
Changed local x to 2
x is now 100
Page |3
30 What will be the output of the following Python code?
def func(a, b=5, c=10):
print('a is', a, 'and b is', b, 'and c is', c)
func(c = 50, a = 100)
y = x[1][0:2]
print(y*2)
a) 22 b) 2222 c) 1111 d) 11
myfile = open("test.bin",'wb')
pickle._____________ # Statement 1
myfile.close()
Page |4
36 Evaluate the following expression and identify the correct answer.
22 - (3 + 2) * 7 + 2**3 * 4
a) 56 b) 19 c) 18 d) 22
37 What will be the output of following:
def ChangeVal(M,N):
for i in range(N):
if M[i]%5==0:
M[i]//= 5
if M[i]%3== 0:
M[i]//=3
L=[25,4,75,91]
ChangeVal(L,4)
for i in L:
print (i, end="#")
---------------------------------------------------------------------------------------------
a) 5#4#5#91#
b) 25#4#75#91#
c) 1#4#1#91#
d) 5#4#3#91#
Page |5
41
What will be the output of the following code:
i = 100
def show(N):
global i
i = 25
if N%5= =0:
i=i+N
print(i, "@", i)
else:
i=i-N
print(i, "@", i)
show(20)
a) 100 @ 100 b) 45 @ 45
c) 20 @ 100 d) 5 @ 30
42 Choose the impossible output from the given options on successful execution of the
following code:
import random
sub=["CS","Maths","Phy","Chem","Eng"]
for i in range(5):
y = random.randint(1,3)
print(sub[y],end="@")
44 What will be the result of execution of python statement f.seek(0), if f is a file object for a text
file?
a. Current file pointer/cursor position will be printed
b. The cursor will be placed at the end of the file
c. The cursor will be placed at the beginning of file
d. The cursor will be placed at the beginning of the current line
Page |6
45 Which of the following statements is true?
a. load method of pickle module gives error if EOF is reached
b. load method of pickle module returns an empty string is EOF is reached
c. load method of pickle module returns -1 if EOF is reached
d. None of the above
46
following code will display:
def records():
num=0
try:
print("Emp id \t Emp Name \t Emp pay")
while True:
rec=pickle.load(fobj)
if rec[2]< 20000:
print(rec[0],"\t\t",rec[1],"\t\t",rec[2])
except:
fobj.close()
records( )
48 Identify the lines that have an error in the following code snippet.
1 N=25
2 for i in range(0,N)
3 if N%2=0:
4 print(N*2)
5 elif N%3==0:
6 print(N*3)
7 Else
8 print(N)
a) 2, 3 only b) 3, 5, 7 only
c) 2, 3, 7 only d) 3, 7 only
49 For the following python code, what will be the datatype of variables x, y, z given that the
code runs without any error?
x = f.read(1)
y = f.readline()
z = f.readlines()
Page |7
Section - C
Case Study based Questions
This section consists of 6 Questions (50 - 55) Attempt any 5 questions.
Pariksha of Class XII is writing a program to add 10 more records to an existing CSV file
payroll
fields. She has written the following code. As a programmer, help her to successfully
execute the given task.
Incomplete Code
__________________ #Statement-1
f1 = open(_________, ________, newline=' ') #Statement-2
empw = csv._________ #Statement-3
details = [ ]
for i in range(10):
empid = int(input("Enter Employee Id : "))
empname = input("Enter Employee Name : ")
designation = input("Enter Designation : ")
salary = int(input("Enter Salary : ") )
record = [ _____________ ] #Statement-4
details.___________ (record) #Statement-5
empw. writerows( ___________ ) #Statement-6
f1.close( )
50 Identify the suitable code for blank space in the line marked as Statement-1.
(a) load CSV (b) read csv
(c) import csv (d) import CSV
51 Identify the missing code for blank space in line marked as Statement-2.
(a) "payroll.csv","wb"
(b) "payroll.csv","a"
(c) "payroll.csv","w"
(d) "payroll.cvs","a"
52 Choose the function name (with argument) that should be used in the blank space of line
marked as Statement-3.
(a) writer(f1) (b) reader(f1)
(c) read(f1) (d) write(f1)
53 Identify the suitable code for blank space in line marked as Statement-4.
54 Identify the suitable code for blank space in the line marked as Statement-5.
(a) load (b) write
(c) append (d) dump
55 Choose the function name that should be used in the blank space of line marked as
Statement-6 to create the desired CSV File?
(a) record (b) details
(c) empw (d) csv
----x----
Page |8
KENDRIYA VIDYALAYA SANGATHAN, LUCKNOW REGION
Class: XII Session: 2021-22
Computer Science (Code 083)
Practice Test ( Theory: Term-1)
Answer Key
The question paper is divided into 3 Sections - A, B, and C.
Section A consists of 25 Questions (1-25). Attempt any 20 questions.
Section B consists of 24 Questions (26-49). Attempt any 20 questions.
Section C consists of 6 case study based Questions (50-55). Attempt any 5
questions.
All questions carry equal marks (0.77 marks per question).