Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

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 students need to attempt 20 questions.
Section B, consists of Question number 26 to 49 and students need to attempt 20 questions.
Section C, consists of Question number 50 to 55 and students 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. Choose invalid identifier : - A. Comma Separated Value
A. My-age B. Common Shift Value
B. _AGE C. Chief Super Value
C. 1st_Value D. Common Separated Value
D. My Age
7. Which of the following can be used to delete
2. Which one of the followings is a jump statement: item(s) from a dictionary?
A. break A. del statement
B. continue B. get()
C. pass C. getitem()
D. All of the above D. all of these

3. Which of the following is a mutable sequence 8. If no argument is given, then pop() returns and
data type: removes the _____element of the list. Fill in the
A. string Blank space.
B. list A. None
C. tuple B. first
D. All of the mentioned C. last
D. all
4. Suppose t = (1, 2, 4, 3), which of the following is 9. Which method can not be used to read from
incorrect? files?
A. print(t[3]) A. read()
B. t[3] = 45 B. readlines()
C. print(max(t)) C. readline()
D. print(len(t)) D. readlines(<filename>)

5. Which of the following is not a proper file access 10. The file mode is used when user want to
write data into a binary file.
mode? A. rb
A. append B. r+
B. read C. wb
C. write D. w+
D. close
11. Which module is used with binary files?
6. csv stands for: A. math

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


B. csv C. We need to close the file after pickling
C. random D. All of these
D. pickle
19. Which of the following creates a tuple?
12. What is the default delimiter of a csv file: A. tuple1=("a","b")
A. New Line Character ‘\n’ B. tuple1[2]=("a","b")
B. Comma C. tuple1=(5)*2
C. Tab Space D. None of the above
D. Blank Space
20. The _____________ method of pickle module reads
13. What will be the output of below Python code? data from a binary file?
tupl=([2,3],"abc",0,9) A. load( )
tupl[0][1]=1 B. dump( )
print(tupl) C. seek( )
A. ([2,3],"abc",0,9) D. tell( )
B. ([1,3],"abc",0,9)
C. ([2,1],"abc",0,9) 21. Which operator is known as floor division in
D. Error python: -
A. /
14. Best option for the python function is B. %
A. A function is a complete program C. //
B. A function is a block of code identified by its D. **
name
C. A function must return a values 22. Is it necessary to have header line as first line in
D. A function can be called without any call csv file:
A. No
15. What is printed by the following statements? B. Yes
D1 = {"cat":17, "dog":6, "elephant":23, "bear":20} C. Both Yes and No
print ("dog" in D1) D. None
A. True
B. False 23. In which format does the readlines( ) function
C. Error give the output?
D. None A. Integer type
B. list type
16. If you are opening a binary file in read mode, C. string type
then the file must exist otherwise what happens? D. tuple type
A. Compile time error occur
B. Run-time error raises
C. Not any error raises
D. None of these
24. Choose correct output for the following code
17. Which of the following represents mode of both def check(x,y):
writing and reading binary format in file? if x != y:
A. wb+ return x+5
B. wb else:
C. w return y+10
D. w+ print(check(10,5))
A. 15
18. Which statement(s) are related to pickling? B. 20
A. process by which python object is converted to C. 5
a byte stream D. 10
B. dump( ) is used for pickling

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


25. What is the delimiter in following csv file': B. Comma
f=open(‘abc.csv’,delimiter=’\t’): C. Tab Space
A. New Line Character ‘\n’ D. Blank Space

Section – B
Section B consists of 24 questions. Attempt any 20 questions.

26. What type of error is shown by following statement? B. Once


>>>t1 =(1, 2) C. Infinite
>>>t2 D. None of these
A. ValueError
B. TypeError 31. Which command can we use to insert 5 to the third
C. NameError position in list1?
D. None of the above A. list1.insert(3, 5)
B. list1.insert(2, 5)
27. Myfile=open(“class.txt”,”r”) C. list1.add(3, 5)
Str=Myfile.read(12) D. list1.append(3, 5)
The above code will be equal to:
A. file(“class.txt”,”r”).read(12) 32. How do you read data from a binary file
B. Myfile(“class.txt”,”r”).read(12) and after loading display the result also?
C. file(“class.txt”,”r”).myfile.read(12) A. fileobject=open(“mybinary.dat”, ”rb”)
D. myfile(“class.txt”,”r”).read(12) B. fileobject=open(“mybinary.dat”, ”rb”)
objectvar=pickle.load(fileobject)
28. What will be the output of the following code C. import pickle
segment? fileobject=open(“mybinary.dat”, ”rb”)
list1 = [10,20,30,10,40,10] objectvar=pickle.load(fileobject)
print(list1.index(10)) fileobject.close( )
A. [0] D. import pickle
B. [0,3,5] fileobject=open(“mybinary.dat”, ”rb”)
C. 0 objectvar=pickle.dump(fileobject)
D. 1 3 5 fileobject.close( )

29. Find the output of the following python program


for i in range(1,15,4):
print(i, end=’,’)
A. 1,20,3
B. 2,3,4
C. 1,5,10,14 33. Identify the error in the following code:
D. 1,5,9,13 import pickle
mix_data=[‘hundred’,2, [3,4,5]]
with open (‘mixeddata.dat’, ‘rb’) as fout:
pickle.dump(mix_data , fout)
A. Not any error is there
30. How many times will the following code be B. with open (‘mixeddata.dat’, ‘w’)
executed? C. with open (‘mixeddata.dat’, ‘wb’)
a=5 D. None of these
while a>0:
print(a) 34. What will be the result of the following code:
print(“Bye”) def func1(a):
A. 5 times a= a + '1'

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


a=a*2 print(AR[K], end=’#’)
print(a) a. 10#40#70#
>>> func1("good") b. 30#40#50#
A. good c. 50#60#70#
B. good2good d. 40#50#70#
C. good1good1
D. error 39. What will be the output for the below code snippet:
def div(lst,n):
35. Evaluate the following expression and identify the for i in range(0,n):
correct answer. if lst[i]%5==0:
16 - (4 + 2) * 5 + 2**3 * 4 lst[i]+=5
A. 54 else:
B. 46 lst[i]=lst[i]//2
C. 18 lt=[45,20,23,54,5]
D. 32 div(lt, len(lt))
for i in lt:
36. Consider the following code and choose correct print(i,end=’#’)
answer
def nameage(name=”kishan”, age=20): a. 50#25#11.5#27.0#10#
return age,name b. 50#25#11#27#10#
t=nameage(20,”kishan”) c. 50#25#1#0#10#
print(t[1]) d. 225#100#1#0#25#
A. kishan
B. 20 40. You have given a file 'book.txt'
C. (kishan, 20) my kv is best in the world
D. (20,kishan) What will be the output of the following code?
myfile = open("book.txt")
37. Predict the output for the below code snippet: str = myfile.read()
value = 50
size = len(str)
def display (N):
print(size)
global value
myfile.close()
value = 25
A. 27
if N%7 = = 0:
B. 18
value = value + N
C. 22
else:
D. 25
value = value - N
print(value, end=’#’) 41. Predict the output for the below code:
display(20) def func(S):
print(value) k=len(S)
a. 50#50 m= ‘ ‘
b. 50#5 for i in range(0,k):
c. 50#30
if S[i].isalpha( ):
d. 5#50#
m=m+S[i].upper( )
38. Choose the correct output/s from the below code: elif S[i].isdigit( ):
Import random m=m+’0’
AR = [20, 30,40,50, 60, 70] else:
FROM = random.randint(1,3) m=m+’#’
TO = random.randint(2,4) print(m)
for K in range(FROM, TO+1): func(“Python 3.9”)

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


x=x-a
a. python0#0# return(x)
b. Python0#0# print(call(67), end=’#’)
c. PYTHON#0#0 print(call(40),end=’#’)
d. PYTHON0#0# a. 67#40
b. 37#70#
42. Consider the following function/method in python c. 27#60
which reads lines from a text file “INDIA.TXT”, to find d. Indentation Error
and display the occurrence of the word “India”. Find the
missing statement in following code: 45. You have given a file 'school.txt'
I read in class XII. My school name is KV. I like it very
def countword(): much. I live in India
f=open("INDIA.TXT", 'r') What will be the output of the following code?
count=0 infile = open("school.txt")
data=___________ x = infile.read()
word=data.split() y = x.count('in')
for i in word: print(y)
if i.lower()=='india': infile.close()
count=count+1 A. 2
print("no of words=",count) B. 3
f.close() C. 4
D. 5
A. f.read()
B. f.readline() 46. You have given a file 'teacher.txt'
I am a student of class XII. My best teacher is Mr. N.
C. f.readlines( )
K. Singh. He is a very nice person. He teaches me
D. f.write()
computer science. I respect him very much. Every
43. You have given a file 'stu.txt' student loves him.
My kv is the best in the world. I am the best student. What will be the output of the following code?
I like computers. infile = open("teacher.txt")
What will be the output of the following code? x= infile.read()
b = x.count('is')
myfile = open("stu.txt") print(b)
str = myfile.readlines() infile.close()
print(str) A. 2
myfile.close() B. 3
A. read first line C. 4
B. read entire file D. 5
C. read second line
D. None of above 47. To open a file Myfile.txt ,which is stored at
d:\Myfolder, for WRITING , we can use
A. F=open("d:\Myfolder\Myfile.txt","w")
44. Predict the Output for the below code
B. F=open(file="d:\Myfolder\Myfile.txt","w")
a=30
C. F=open(r"d:\Myfolder\Myfile.txt","w")
def call (x):
global a D. F=open("d:\Myfolder\\Myfile.txt","w")
if x%2==0:
x=x+a 48. Assume the content of text file, 'student.txt' is:
else: Ramesh is student

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


Radha is girl D. dictionary
KVS
Jaipur 49.Which of the following Python codes will give same
What will be the data type of data_rec? output tupl=(1,2,3,4)
(i) print(tupl[:-1])
myfile = open("student.txt")
(ii) print(tupl[0:5])
data_rec = myfile.readlines() (iii) print(tupl[0:4])
myfile.close() (iv) print(tupl[-4:])
A. i, ii
A. string B. ii, iv
B. list C. i, iv
C. tuple D.ii,iii,iv

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

Student of class 12 named Tarun, is working on rec=pickle.load(ifile)


Binary File Module in Python. He wants to create print(rec)
copy of “student.dat” binary file named as except EOFError:
“duplicate.dat”. He has missed some logics and
hence the code remained incomplete. Help him to ifile.close()
complete the code So that he can do desired task.
……….………………………. # Statement-1 def display2():
def fileCopy(): ofile = open("duplicate.dat","rb")
ifile = ………………… # Statement-2 print("----Records of Duplicate file---")
ofile =………………… # Statement-3 try:
try: while True:
while True: rec=………………………….. # Statement-5
rec=pickle.load(ifile) print(rec)
………………. # Statement-4 except EOFError:
except EOFError: ofile.close()
ifile.close() ……………………….. # Statement-6
ofile.close() display1()
print("Copied Successfully") display2()

50. Which module is required to import at


def display1(): “Statement-1” for successful execution of the code
ifile = open("student.dat","rb") given in the program?
print("----Records of student.dat file---") A. import csv
B. import binary
try: C. import pickle
while True: D. import text

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


A. pickle.dump(rec,ofile)
B. pickle.load(ofile)
C. pickle.dump(rec,ifile)
51. Identify the missing code for blank space in line D. pickle.load(rec,ifile)
marked as Statement-2. Here he wants to open the
“student.dat” file. 54. He wants to read the records of the
A. open("student.dat","ab") duplicate.dat file. Complete the missing statement
B. open("student.dat","rb") for Statement-5
C. open("student.dat","wb") A. pickle.load(“duplicate.dat”)
D. None of Above B. pickle.read(“duplicate.dat”)
C. pickle.read(ofile)
52. Identify the missing code for blank space in line D. pickle.load(ofile)
marked as Statement-3. Here he wants to open the
“duplicate.dat” file. 55. Write the exact function call at missing
A. open("duplicate.dat","wb") Statement-6. So that duplicate file can create and
B. open("duplicate.dat","r+b") update successfully.
C. open("duplicate.dat","rb") A. display1()
D. None of Above B. display2()
C. fileCopy()
53. Write the missing code for the statement-4 D. All of Above
where the duplicate.dat file should be update with
new record which was read from student.dat file.

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

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

You might also like