You are on page 1of 8

Sample Question Paper (Term-I)

Class : XII Time Allowed : 90 Minutes


Subject : (083) Computer Science Maximum Marks: 35

General instructions:
The paper is divided into 3 Sections- A, B and C.
Section A, consists of Question 1 to 25 and student need to attempt 20 questions.
Section B, consists of Question number 26 to 49 and student need to attempt 20 questions.
Section C, consists of Question number 50 to 55 and student need to attempt 5 questions.
All questions carry equal marks (0.77 mark per question).

Section – A
Section A consists of 25 questions, attempt any 20 questions
1. Select correct Boolean literal : - 5. In computer Binary Files are stored in term
A. true of:
B. TRUE A. Bit
C. false B. Nibble
D. True C. Bytes
D. Mnemonics
2. Which one of the following is not a
keyword: 6. If we want to know the current file position,
A. if which method can be applied:
B. else A. seek()
C. While B. tell()
D. try C. ask()
D. position()
3. Predict the output of the following code
def fun2(list1): 7. The position of a file-pointer is governed by
for x in list1: the___________
print(x.upper(),end=”#”) A. File mode
fun2([‘Rajesh’,’Kumar’) B. append mode
C. write mode
A. [RAJESH,KUMAR] D. open mode
B. RAJESH#KUMAR#
C. RAJESHKUMAR# 8. Which of the following statement in python
D. Rajesh#Kumar# is not correct after using:import csv
A. csv.DictReader(Required Attributes)
4. Which command can we use to insert 5 at B. csv.DictWriter(Required Attributes)
the third position in list1? C. csv.dump(Required Attributes)
A. list1.insert(3, 5) D. csv.reader(Required Attributes)
B. list1.insert(2, 5)
C. list1.add(3, 5)
D. list1.append(3, 5) 9. Write the output of the following.
A = tuple(“Python”)

1 | KVS – Regional Office, JAIPUR | Session 2021-22


print(A) A. Tells the current position within the file
A. (python) B. It confirms whether you can move to the
B. (“Python”) position in file or not.
C. (‘P’ , ‘y’ , ‘t’ , ‘h’ , ‘o’ , ‘n’) C. Indicates from where next read or write
D. None of the above will take place
D. Moves the current position of file object to
10. Choose correct answer a given specified position
def fun1(num):
return num+5 15. A function may have: -
print(fun1(5)) A. Keyword arguments
print(num) B. Default Arguments
C. Positional arguments
A. Print value 10 D. All of the above
B. Print value 5
C. Name Error 16. Write the output of the following:
D. 25 a=(“Amit”, “Sumit”,”Ashish”,”Sumanta”)
print(max(a))
11. Which option is correct about this program? A. Sumanta
f=open(“ss.txt”,”wb”) B. Ashish
print(“Name of the file:”,f.name) C. Sumit
f.flush() D. Amit
f.close()
17. Identify correct output
A. Compilation error def fun3(a,b,c):
B. Runtime error return a+1,b+2,c+3
C. No output t=fun3(10,20,30)
D. Flushes the file when closing them print(t)

12. In tuples values are enclosed in _____________ A. 11,22,33


A. Square brackets B. 11 22 33
B. Curly brackets C. (11, 22, 33)
C. Parenthesis D. (11 22 33)
D. None of the above

13. Which file can open in any text editor and is 18. To open a file c:\scores.txt for writing, we
in human readable form? use ____________
A. Binary files A. outfile = open(“c:\scores.txt”, “w”)
B. Video files B. outfile = open(“c:\\scores.txt”, “w”)
C. Data files C. outfile = open(file = “c:\scores.txt”, “w”)
D. Text files D. outfile = open(file = “c:\\scores.txt”, “w”)

19. Which of the following is not a tuple?


A. P = 1,2,3,4,5
B. Q = (‘a’, ‘b’, ‘c’)
C. R = (1, 2, 3, 4)
D. None of the above
14. Which of the statements correctly explains 20. Which of the following statement in python
the concept of seek() method: is correct after using: import csv

2 | KVS – Regional Office, JAIPUR | Session 2021-22


A. CSV.error(Required Attributes) 23. Which keyword is used to access a global
B. Csv.DictWriter(Required Attributes) variable in a function: -
C. csv.writer(Required Attributes) A. non local
D. CSV.reader(Required Attributes) B. global
C. def
21. What will be the result of the following D. return
code?
dict = {"Jo" : 1, "Ra" : 2} 24. Harish developed a python code to update a
dict.update({"Ph":2}) binary file “Stock.dat”, He opened file using
print (dict) command with open(“Stock.dat”, “rb+”) as

A. {"Jo":1,"Ra" :2, "Ph" : 2} f: later he realized that he forgot to close the


B. {"Jo":1,"Ra":2} file in program, what can be the
C. {"Jo":1,"Ph" :2} consequences:
D. Error
A. file will be closed automatically
22. The data files can be stored as: B. data written file will get deleted
A. text files C. file will not open in next run
B. binary files D. unpredictable
C. csv files
D. all of these 25. To calculate 2 raised to the power 5 which
of following can be used: -
A. pow(2,5)
B. 2 ** 5
C. Both A and B
D. None
Section – B
Section B consists of 24 questions, attempt any 20 questions.

26. Write the output of the following: A. read first line


t1 = (1,2) B. read entire file
t2 = (2,1) C. read second file
t1 == t2 D. None of above
A. True
B. False 28. What will be the output of the following code
C. Error segment?
D. None of the above l=['A','a','Aa','aA']
print(max(l))
27. You have given a file 'stu.txt' A. 'aA'
my kv is best in the world. i am a best student. B. 'A'
i like computer. C. 'a'
What will be the output of the following code? D. 'Aa'
myfile = open("stu.txt")
str = myfile.readlines()
print(str)
myfile.close()

3 | KVS – Regional Office, JAIPUR | Session 2021-22


29. How many times will the following code be A. Line 1: pickle.dump(file1)
executed Line 2: CINEMA[‘Mtype’]== ‘Comedy’:
for i in range(1,15,5):
print(i,end=’,’) B. Line 1: pickle.load(file1)
A. 3 Line 2: CINEMA[‘Mtype’]== ‘Comedy’:
B. 4
C. 1 C. Line 1: load(file1)
D. infinite Line 2: CINEMA[‘Mtype’]== ‘Comedy’:

30. What is the output of the following ? D. Line 1: pickle.dump(file1)


x = 123 Line 2: ‘Mtype’== ‘Comedy’:
for i in x:
print(i) 33. Following code is written to update a
A. 123 record in file opened with following code.
B. 1 2 3 What will be there in blanks mentioned
C. error as Line1 and Line2 in the following code:
D. infinite import pickle
fin=open(‘emp.dat’, ‘rb+’)
31. What will be the output of the following code try:
segment? while True:
list1 =['Red', 'Green', 'Blue', 'Cyan', 'Magenta', ____________=fin.tell( ) #line 1
'Yellow', 'Black'] stu=pickle.load(fin)
print(list1[-4:0:-1]) if emp[‘sal’] in[2000, 5000 10000]:
A. ['Cyan', 'Blue', 'Green', 'Red'] emp[‘sal’] +=500
B. [] fin.______ (__________) #line 2
C. ['Cyan', 'Blue', 'Green'] pickle.dump(emp, fin)
D. ['Cyan', 'Magenta', 'Yellow', 'Black'] except EOFError:
fin.close( )
32. Following code is the definition of a
dictionary CINEMA, with a method A. Line 1: position= fin.tell( )
in python to search and display all Line 2: fin.seek(position)
content in a pickled file Cinema.dat, B. Line 1: position= fin.tell( )
where Mtype key of dictionary is Line 2: fin.tell(position)
matching with the value ‘Comedy’. C. Line 1: fin.seek( )
What will be there in blanks mentioned as Line 2: fin.tell(position)
Line1 and Line2 in the following code: D. Line 1: fin.seek( )
CINEMA={‘MNO’:____B ,’MNAME’:___, ’MTYPE’:____} Line 2: fin.tell( )
import pickle
def Search( ): 34. Choose correct answer
file1=open(‘Cinema.dat’, ‘rb+’) def fun1(num):
try: return num+5
while True: print(fun1(5))
CINEMA=__________________#Line1 print(num)
if__________________________ #line2 A. Print value 10
print(CINEMA) B. Print value 5
except EOFError: C. Name Error
file.close( ) D. 25

4 | KVS – Regional Office, JAIPUR | Session 2021-22


35. What is the output of this expression,
3*1**3? 39. What is the output of the following code snippet?
A. 27 def minmax(lst):
B. 9 s=l=lst[0]
C. 3 for i in lst:
D. 1 if i>l:
l=i
36. Identify correct output for the following code if i<s:
def fun4(a,b=100): s=i
total=a+b print(s,l)
print(total) lt=[45,2,23,54,5]
fun4(50,20) minmax(lt)
A. 100 a. 2,5
B. 120 b. 2,23
C. 150 c. 2,54
D. 70 d. 54,2

40. Given a file 'stu.txt'


37. Choose the correct option: my kv is best in the world. i am a best student.
Statement1: Local Variables are accessible only
i like computer.
within a function or block in which it is declared.
Statement2: Global variables are accessible in the What will be the output of the following code?
whole program. myfile = open("stu.txt")
a. Statement1 is correct but Statement2 is str = myfile.readlines()
incorrect lcount = len(str)
b. Statement2 is correct but Statement1 is print(lcount)
incorrect myfile.close()
c. Both Statements are Correct
(A) 1
d. Both Statements are incorrect
(B) 2
38. Based on the below code snippet. Find the (C) 3
maximum and minimum value assigned to variable (D)4
FROM.
Import random 41. What is the output of the following code
AR = [20, 30,40,50, 60, 70] snippet?
FROM = random.randint(1,3) def short (lst, n):
TO = random.randint(2,4) for i in range (0,n):
for K in range(FROM, TO+1): if len(lst[i]>4):
print(AR[K], end=’#’) lst[i] = lst[i][0:4]
a. 1,3 else:
b. 4,1 lst[i]=lst[i]
c. 1,4 sub=[‘IP’, ’HINDI’, ’CS’, Mathematics’, ‘Chemistry’,
d. 3,1
‘Physics’]
short(sub,6)
for i in sub:
print(i, end=’ , ’)

5 | KVS – Regional Office, JAIPUR | Session 2021-22


else:
a. IP,HINDI,CS,Mathe,Chemi,Physi, x=x-a
b. IP,HIND,CS,Math,Chem,Phys, return(x)
c. IP,HINDI,CS,Mathematics,Chemistry,Physics x=20
d. IP,HIN,CS,Mat,Che,Phy, print(call(35), end=’#’)
print(call(40),end=’#’)
42. What will be the output of the following Python a. 5#70#
code? b. 65#70#
f=None c. 60#70
for i in range(5): d. Indentation Error
with open(“data.txt”,”w”) as f:
if i>2: 45. Read the code given below and answer the
break question:
print(f.closed) f=open(“sample.txt”,’w’)
(A)True f.write(“Morning”)
(B)False f.close()
(c)None If the file contains “Good” before execution, what
(D)Error will be the contents of the file after execution of this
code?
43. Considering the following function/method in (A) Good Morning
python which read lines from a text file (B) Good
“INDIA.TXT”, to find and display the occurrence of
(C)Morning
the word “India”. Find the missing statement in
following code: (D) None of these
def countword():
f=open("INDIA.TXT", 'r') 46. What error is returned by following statement,
if file “try.txt” does not exist?
count=0
f = open(“try.txt”)
data=___________
A. Not found
word=data.split()
B. FileNotFoundError
for i in word:
C. File does not exist
if i.lower()=='india':
D. No error
count=count+1
print("no of words=",count) 47. You have given a file 'stu.txt'
f.close() my kv is best in the world. i am a best student.
(A) f.read() i like computer.
(B) f.readline() What will be the output of the following code?
(C) f.readlines myfile = open("stu.txt")
(D) f.write() str = myfile.readlines()
print(str)
44. Predict the Output for the below code myfile.close()
a=30
A. read first line
def call (x):
global a B. read entire file
if a%2==0: C. read second file
x=x+a D. None of above

6 | KVS – Regional Office, JAIPUR | Session 2021-22


B. moves file pointer to 6th position from current
48. What is the purpose of line1 in following python location in file
code? C. moves file pointer to 6th position before the end
f = open("data.txt", 'r+')
of file
print(f.tell())
D. tells the current position of file pointer in file
print(f.read(6))
print(f.tell()) 49. Write the output of the following:-
print(f.read()) a=(23,34,65,20,5)
print(f.tell()) print(a[0]+a.index(5))
f.seek(6,0) # line1 A. 28
A. moves file pointer to 6th position from B. 29
C. 27
beginning of file
D. 26

Section – C
Section C consists of 06 questions, attempt any 05 questions.

Latika is making software on “Items & their prices” A. @


in which various records are to be stored/retrieved B. :
in STORE.CSV data file. It consists some records C. ,
(Item & Price). She has written the following code D. .
in python. As a programmer, you have to help her to
successfully execute the program. 52. Which file mode to be passed to add new record
import ___________ # Statement-1 in Statement-3.
def AddItem(Item,Price)___ # Statement-2 A. w+
f=open(“STORE.CSV”,_________) # Statement-3 B. w
fw=csv.writer(f) C. wb
fw.writerow([Item,Price]) D. a
____________ # Statement-4
def ShowRecord(): 53. What should be written in Statement-4 to close
with open(“STORE.CSV”,”r”) as NI: the file?
NewItem=csv.___________(NI) # Statement-5 A. close()
for rec in NewItem: B. fw.close()
print(rec[0], “#”, rec[1]) C. f.close()
AddItem(“Sugar”, 38.0) D. csv.close()
AddItem(“Rice”, 48.50)
ShowRecord() # Statement-6 54. Which function to be used in Statement-5 to
read the data from a csv file.
50. Which module should be imported in A. read()
Statement-1. B. readline()
A. pickle C. readlines()
B. csv D. reader()
C. file
D. text
51. Which symbol is missing in statement-2 55. The output after executing Statement-6 will be –

7 | KVS – Regional Office, JAIPUR | Session 2021-22


A. (“Sugar”, “38.0”) C. Sugar, 38.0
(“Rice”, “48.50”) Rice, 48.50
B. Sugar 38.0 D. Sugar # 38.0
Rice 48.0 Rice # 48.50

0-O-o- Best of Luck –o-O-0

8 | KVS – Regional Office, JAIPUR | Session 2021-22

You might also like