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

KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION

PRE BOARD EXAMINATION (TERM-I) (Code – 001)


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 number 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. Which of the following statement is incorrect?


A. X=*Y 5. Negative index -1 belongs to ______ of string.
B. My_name = ’Deepesh’ A. first character
C. While = 400 B. second character
D. None of these C. second last character
D. last character
2. Consider a declaration L = (35)
Which of the following represents the datatype 6. What will be the output of the following code
of L? segment?
A. Tuple Lst=['KV', 'is', 'the', 'best', 'school', 'in', 'India']
B. List print(Lst[ : : 4])
C. Integer
D. Dictionary A. [‘KV’, ‘is’,’the’,’best’]
B. [‘KV’, ‘best’, ‘India’]
3. Which of the following is not used to repeat C. ['KV', 'School']
some code in Python? D. [‘KV’, ‘is’,’the’, ‘best’,’school’]
A. for loop
B. do-while loop 7. Which of the following is a Python tuple?
C. while loop A. (11, ‘is’, ‘my’, ‘class’)
D. None of the above. B. {11, ‘is’, ‘my’, ‘class’}
C. (11, is, ‘my’, ‘class’]
4. The _________ statement terminates the D. {}
execution of the whole loop.
8. Which of the following is/are features of list?
A. continue A. List is mutable
B. break B. List is a sequence data type.
C. breake C. List[: : -1] prints reverse of the list
D. exit D. All of the above

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


9. Which of the following functions will return the 15. What is the use of “w” in file handling?
key, value pairs of a dictionary? A. Read
A. keys() B. Append
B. values() C. Write
C. items() D. None of the mentioned
D. all of these
16. Write full form of csv:
10. Choose correct answer A. Comma settled values
t=['Marks', 'of', 'Yash', [34, 43, 41, 38]] B. Common separated values
print(t[: : -1]) C. Comma separated values
A. [[38, 41, 43, 34], 'Yash', 'of', 'Marks'] D. None of the above
B. [[34, 43, 41, 38], 'Yash', 'of', 'Marks']
C. [[38, 41, 43, 34], 'hsaY', 'fo', 'skraM'] 17. Which function is used to save data in binary
D. [[83, 14, 34, 43], 'hsaY', 'fo', 'skraM'] files?
A. Load()
11. Predict the output of the following code: B. dumb()
def myFunc(n1, n2): C. load()
for x in range(n1, n2): D. dump()
if n1%x==0:
print(x, end=' ') 18. Which statements are true about the blocks in
myFunc(10, 20) exception handling?
A. Exception is raised in try
A. 10 12 14 16 18 20 B. Exception is handled in except
B. 12 16 20 C. The statements written within finally block
C. 10 20 are always executed regardless of whether an
D. 10 exception occurred in try block or not.
D. All of these
12. Which of the following is not a python
functions type: 19. Which of the following statement opens a binary
A. Module function file record.bin in write mode and writes data
B. User-defined function from a list lst1 = [1, 2, 3] on the binary file?
C. Random function A. with open('record.bin','wb') as myfile:
D. Built-in-function pickle.dump(lst1,myfile)
B. with open('record.bin','wb') as myfile:
13. The extension of text file is ____, and extension pickle.dump(myfile,lst1)
of python code file is ______. C. with open('record.bin','rb') as myfile:
A. .txt, .pyt pickle.dump(myfile,lst1)
B. .py, .txt D. with open('record.bin','ab') as myfile:
C. .pyt, .text pickle.dump(myfile,lst1)
D. .txt, .py
20. Alankar wants to check whether her name is
14. When reading a file using the file object, which listed in list.dat or not. Which command he can
method is best for reading the entire file into a write to open the file:
single string? A. a=open(“list.dat”,”rb”)
A. readline() B. with open (“list.dat’,’rb”) as a:
B. read() C. None
C. READ() D. Both a and b
D. readlines()

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


21. To write data into binary file which mode will 23. The CSV files can be operated by___ software.
be used? A. Spreadsheet
A. wb B. Notepad
B. r+ C. MS Excel
C. rb D. All of the above
D. w+
24. Which of the following is not a function/
22. Syntax for opening student.csv file in write method of csv module in Python?
mode is A. reader()
myfile = open("student.csv", "w", newline=''). B. read()
What is the importance of newline=' ' ? C. writer()
D. writerow()
A. A newline gets added to the file
B. Empty string gets appended to the first line. 25. Most commonly used software for opening csv
C. Empty string gets appended to all lines. file in windows is:
D. EOL translation is suppressed A. Acrobat Reader
B. Microsoft word
C. Microsoft Excel
D. Google Chrome

Section – B
Section B consists of 24 questions, attempt any 20 questions.

26. Write the output of the following: 28. Given list1 = [10, 20, 30, 40, 50]
name = ['Nischay', 'Manoj', 'Nirbhaya', 'Nilu'] Statement 1: list1[: : -1]
print(max(name)) Statement 2: list1.reverse()
Which statement modifies the contents of
A. Manoj original list1.
B. Nilu A. Statement 1
C. Nirbhaya B. Statement 2
D. Nischay C. Both Statement 1 and 2.
D. None of the mentioned
27. Read the code given below and answer the
question: 29. What will be the output when the following code
f=open(“sample.txt”,’w’) is executed?
f.write(“Morning”) >>> str1="Nitin”
f.close() >>> str1[: : -1]
A. nItIN
B. Nitin
If the file contains “Good” before execution, C. nitiN
what will be the contents of the file after D. NiTiN
execution of this code?
30. Find output of the following code:
A. Good Morning for I in range (15, 9, -2):
B. Good print(I, end=’ ‘)
C. Morning A. 15 13 11
D. None of these B. 15 13 11 9
C. 15 14 13 12 11 10 9
D. 15 14 13 12 11 10

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


31. What will be the output of the following code 35. What is the output of "hello" +str(123+321)?
segment?
l=list(range(100,20,-20)) A. hello123321
print(l) B. hello444
A. [100, 80, 60, 40] C. Error
B. [100, 80, 60, 40] D. hello132231
C. [100, 20, -20]
D. Error 36. Consider the following code and choose correct
answer:
32. Choose the correct code to write one record of def nameage(name, age):
student (Rno, Name, Gender, Marks) in binary return [age, name]
file named mybinary.dat? t=nameage(“Kanak Sharma”, 20)
print(type(‘t’))
A. fileobject=open(“mybinary.dat”, ”wb”)
B. fileobject=open(“mybinary.dat”, ”wb”) A. tuple
pickle.dump(listvalues, fileobject) B. list
C. import pickle C. (‘Kanak Sharma’,20)
listvalues=[1,”Prabal” ‘M’, 16] D. string
fileobject=open(“mybinary.dat”, ”wb”)
pickle.dump(listvalues, fileobject) 37. What is the output of the program given
D. import pickle below?
listvalues=[1,”Prabal” ‘M’, 16] >>> def myFunc(x):
fileobject=open(“mybinary.dat”, ”wb”) L=[k for k in range(0, x ,2)]
pickle.dump(listvalues, fileobject) print(L*2)
fileobject.close( ) >>> myFunc(5)

33. Find the output of the following code: A. [ 0, 2, 4, 0, 2, 4 ]


>>> L1=[25,65,85,47] B. [ 0, 4, 8 ]
>>> L2=(L1) C. Both A and B
>>> L1[2]=100 D. Error because we cannot multiply List
>>> print(L1,'\t',L2)
A. [25, 65, 100, 47] [25, 65, 85, 47] 38. Based on the below code, What maximum value can
B. [25, 65, 85, 47] [25, 65, 85, 47] be assigned to FROM and minimum value can be
C. [25, 65, 100, 47] [25, 65, 100, 47] assigned to TO.
D. [25, 65, 85, 47] [25, 65, 100, 47]
import random
34. What is the output of the program given below? AR = [20, 30, 40, 50, 60, 70]
a = 100 FROM = random.randrange(1, 3)
def func (a) : TO = random.randrange(2, 4)
a = 20 for K in range(FROM, TO+1):
func (a) print(AR[K], end=’#’)
print (' a is now ', a)
A. 2, 3
A. a is now 50 B. 2, 2
B. a is now 100 C. 3, 2
C. a is now 2 D. 2, 1
D. error

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


A. 0
39. Choose correct output for the following code B. 2
def check(x, y): C. 1
if x != y:
D. 3
return x+5
else:
return y+10 42. You have given a file 'teacher.txt'
print(check(10, 5))
I am a student of class XII. My best teacher
A. 15 is Mr. P. Singh. He is very nice person. He
B. 20 teaches me CS and IP. I respect him very
C. 5 much. Every student love him.
D. 10

40. You have given a file 'school.txt'. The content is What will be the output of the following code?
infile = open("teacher.txt")
I read in class XII. My school name is KV. x = infile.read()
I like very much. I live in India b = x.count('is') + x.count(‘very’)
print(b)
What will be the output of the following code? infile.close()
infile = open("school.txt")
x = infile.read() A. 2
y = x.count('in') B. 3
print(y) C. 4
infile.close() D. 5

43. Which function reads some bytes from the text


A. 2
file and returns it as a string?
B. 3 A. read()
C. 4 B. readline()
D. 5 C. readlines()
D. readall( )
41. Consider the code given below and identify how
many times the message “all the best” will be 44. Write the output for the below code:
printed
def prog(name): def mysum(a=100, b=200, c=300):
for x in name: return (a+b+c)
if x.isalpha():
print(“alphabet”) p, q , r=10, 20, 30
elif x.isdigit():
print(“digit”) print(mysum(p, r), '\t', mysum())
elif x.isupper():
print(“upper”) A) 60 600
else: B) 350 600
print(“all the best”) C) 340 600
D) 330 600
prog(“ramesh143@kvsrojaipuronline.in”)

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


45. Consider the below statement 47. Choose the correct option for mode
Data=F.read(10). file1=open("notes.txt", )
Which of the following statement is True ch=file1.read()
regarding variable Data? print(ch)
file1.close()
A. Data contains list of 10 lines
B. Data contain list of 10 characters A. w
C. Data contains string of 10 characters B. a
D. Data contains integer value 10 C. r
D. All of the above

46. You have given a file 'book.txt' 48. Consider the below code snippet and write the
missing part in statement4
myfile = open("student.txt") #Statement1
My KV is best in the world
data_rec = myfile.read() #Statement2
print(data_rec) #Statement3
What will be the output of the following code?
myfile._______ #Statement4
myfile = open("book.txt")
A. close
str = myfile.read()
B. close( )
size = len(str.split())
C. closed
print(size)
D. closed()
myfile.close()
49. Write the output of the following:
A. 26 a=(1, 2, 3, 2, 3, 4, 5)
B. 18 print(min(a) + max(a) + a.count(2))
C. 22
D. 7 A. 13
B. 6
C. 8
D. Error

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


Section – C
Section C consists of 06 questions, attempt any 05 questions.
Raj Kuntal is collecting data of criminal persons and the
prize money on them with their location. He is 51. Which symbol is missing in Line 2?
storing/retrieving data from a file CRIMINAL.CSV. It A. ::
consists some records (sno, name, money, location). He B. ,
has written the following code in python. As a C. @
programmer, you have to help him to successfully D. :
execute the program.
52. Which statement will be written at Line 4?
A. f.close
import ___________ # Line 1 B. obj.close()
def addRecord(Lst) # Line 2 C. f.close()
f=open(“CRIMINAL.CSV”, ___ ) # Line 3 D. obj.close
obj=csv.writer(f)
obj.writerow(Lst) 53. Which function to be used in Line 5 to read the
_______ # Line 4 data from a csv file.
A. read()
def ShowRecord(): B. readline()
with open(“CRIMINAL.CSV”, ”r”) as file: C. readlines()
obj=csv.___________(file) # Line 5 D. reader()
for rec in obj:
print(rec[0], “#”, rec[2]) 54. The output after executing Line 6 will be :
A. 1#Jaipur
Criminal_1=[1,’XYZ’, 500, ‘Jaipur’] 2#Bharatpur
Criminal_2=[2,’PQRYZ’, 1500, ‘Bharatpur’] B. 1#500
2#1500
addRecord(Criminal_1) C. XYZ#500
addRecord(Criminal_2) PQRYZ#1500
ShowRecord() # Line 6 D. XYZ#Jaipur
PQRYZ#Bharatpur

50. Which module should be imported in Line 1? 55. Which file mode to be passed to add new record
A. pickle in Line 3?
B. csv A. a
C. file B. w
D. text C. w+
D. wb

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

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

You might also like