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

KENDRIYA VIDYALAYA SANGATHAN, LUCKNOW REGION

Class: XII Session: 2021-22


Computer Science (Code 083)
Practice Test ( Theory: Term-1)
Maximum Marks: 35 Time Allowed: 90 Minutes
General Instructions:

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).

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

12 Which of the following function headers is correct?


a) def fun(a = 2, b = 3, c)
b) def fun(a = 2, b, c = 3)
c) def fun(a, b = 2, c = 3)
d) def fun(a, b, c = 3, d)
13 What will be the output of following:
>> round(4.5676,2)
a) 4.57 b) 4.56 c) 5.00 d) 4.6
14 If a file opens as fp=open('Poem.txt','r') then which statement is incorrect?
a) fp.read( ) b) fp.tell( )
c) fp.write( ) d) none of these

15 Consider the following python program.


import csv
fp = open("Employee.csv","r")
data = csv.reader(fp)
for myRec in data:
print(myRec)
What will be the data type of myRec?
a) string b) tuple c) list d) dictionary

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

19 In regards to separated value files such as .csv what is the delimiter?


a) Delimiters are not used in separated value in the file
b) Anywhere the comma (,) character is used in the file is called delimiter
c) comma (,) that is used to separate the column data.
d) None of these

20 CSV file writer( ) function write the data in ___________ form.


a) Binary b) Dictionary c) List d) String

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]

27 To insert 5 to the third position in list1, we use which command?


a) list1.insert(3, 5)
b) list1.insert(2, 5)
c) list1.add(3, 5)
d) list1.append(3, 5)

28 Which of these about a dictionary is false?


a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values

d) Dictionaries are mutable

29 What will be the output of the following Python code?


x = 50
def func(x):
print('x is', x)
x=2
print('Changed local x to', x)
func(x)
print('x is now', x)

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)

a) a is 5 and b is 100 and c is 50


b) a is 50 and b is 100 and c is 5
c) a is 100 and b is 5 and c is 50
d) None of the mentioned
31 Identify the output of the following python code.

y = x[1][0:2]
print(y*2)

a) 22 b) 2222 c) 1111 d) 11

32 Identify the output of the following Python statements.


x = [[10.0, 11.0, 12.0],[13.0, 16.0, 18.0]]
y = x[1][1]
print(y)
a) 11.0 b) 12.0 c) 16.0 d) 18.0
33 What is a variable defined outside a function referred to as?
a) A static variable
b) A global variable
c) A local variable
d) An automatic variable
34 What will be the output of following code:
x=0
def change(x):
x=x+1
return x
change(5)
print(x)
a) 1 b) Nothing is displayed
c) 0 d) An exception is thrown

35 Munendra is trying to write an object on a binary file


"test.bin". Consider the following code written by him.
import pickle

myfile = open("test.bin",'wb')
pickle._____________ # Statement 1
myfile.close()

Identify the missing code in Statement 1.


a. dump(myfile, myData) b. dump(myData, myfile)
c. write(myData,myfile) d. load(myfile, myData)

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#

38 What will be the output of the following Python code snippet?


for x in [1, 2, 3, 4][: :-1]:
print (x )
a) 1 2 3 4 b) 4 3 2 1
c) error d) none of the mentioned

39 What will be the output of the following Python code?


x = 'abcd'
for k in range(len(x)):
print( k )

a) a b c d b) 0123 c) error d) 1234

40 Suppose content of 'book.txt' is:


open a book
and you will find,
people and places of every
kind
open a book
and you can be

What will be the output of the following code?


f = open("book.txt", "r")
x = f.readlines()
print(x[-1])
a) open a book b) open a book
and you will find and you can be
c) people and places of every kind d) and you can be

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="@")

(a) Phy@Chem@Eng@Phy@ (b) CS@Chem@Eng@Phy@


(c) Phy@Chem@Eng@Eng@ (d) Chem@Chem@Phy@Phy@

43 Suppose content of 'lang.txt' is:


It is interpreted.
It is High level.
Indentation is important.
What will be the output of the following code?
f = open("lang.txt")
r = f.read( )
L = r.split( )
c=0
for i in L:
if i[0].isupper( ):
c += 1
print(c)
f.close( )

(a) 3 (b) 9 (c) 4 (d) 6

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( )

a. Display the details of those employee whose pay is above 20000.


b. Display the details of all the employees.
c. Display the pay of all the employees.
d. Display the details of those employees whose pay is less than 20000.
47 Which of the following statements will not evaluate to True?
a) [1,2,3,4] < [4] b) [1,2,3] < [3,2,1]
c) [1,2,3,5] < [1,2,3,4,5] d) [3,2,1] > [2,3,4]

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()

a) string, list, list b) None, list, list


c) string, string, list d) string, string, string

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.

(b) empid, empname, designation, salary


(c) EMPID,NAME,DESIGNATION,SALARY
(d) emp id, name, designation, salary

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).

Correct Correct Correct


Ques. No Ques. No Ques. No
Opt Opt Opt
1 A 21 B 41 B
2 C 22 D 42 D
3 B 23 C 43 A
4 C 24 D 44 C
5 B 25 B 45 A
6 D 26 C 46 D
7 B 27 B 47 D
8 C 28 B 48 D
9 D 29 B 49 A
10 A 30 C 50 C
11 C 31 C 51 C
12 C 32 C 52 A
13 A 33 B 53 B
14 C 34 C 54 C
15 C 35 B 55 B
16 D 36 B
17 A 37 A
18 C 38 B
19 C 39 B
20 C 40 D
---X

Question Paper prepared by : Deepak Singh Gosain

PGT Computer Science, KV Pilibhit

You might also like