North Cluster Examination 2021-2022 Class: Xii Subject: Computer Science
North Cluster Examination 2021-2022 Class: Xii Subject: Computer Science
North Cluster Examination 2021-2022 Class: Xii Subject: Computer Science
CLASS : XII
SUBJECT: COMPUTER SCIENCE[083]
Maximum Marks: 35 Time Allowed: 90 Minutes
General Instructions:
● The question paper is divided into 3 Sections - A, B and C.
● Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
● Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
● Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
● All questions carry equal marks.
Q.N Section-A
.
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from
this section. Choose the best possible option.
1 What type of error is returned by following statement?
print(int("a"))
a. Syntax error b. ValueError c. TypeError d. None of the above
2 What is the minimum and maximum value of 'A' in the following statement..
import random
A=random.randint(2,30)
print(A)
a.3 and 30 b. 2 and 3 c. 02 and 29 d. 2 and 30
3 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90)
What will be the output of print (tup1 [3:7:2])?
a. (40,50,60,70,80) b. (40,50,60,70) c. [40,60] d. (40,60)
4 Write the value that will be assigned to variable a
A=20*5+3**2%2//5
a. 101 b. 100 c. 1.9 d. none of these
5 Which of the following option is not correct?
a. if we try to read a text file that does not exist, an error occurs.
b. if we try to read a text file that does not exist, the file gets created.
c. if we try to write on a text file that does not exist, no error occurs.
d. if we try to write on a text file that does not exist, the file
gets Created.
6 Which of the following options can be used to read the first line of a text file Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()
7 Assume that the position of the file pointer is at the beginning of 3rd line in a text file.
Which of the following option can be used to read all the remaining lines?
a. myfile.read() b.myfile.read(n) c.myfile.readline() d.myfile.readlines()
8 Which of the following statement is incorrect in the context of binary files?
a. Information is stored in the same format in which the information is held in memory.
b. No character translation takes place
c. Every line ends with a new line character
d. pickle module is used for reading and writing
9 Which of the following statements correctly explain the function of seek() method?
(a) tell the current position within the file.
(b) indicate that the next read or write occurs from that position in a file.
(c) determine if you can move the file position or not.
(d) move the current file position to a different location at a defined offset.
10 A text file student.txt is stored in the storage device. Identify the correct option out of
the following options to open the file in read mode.
i. myfile = open('student.txt','rb')
ii. myfile = open('student.txt','w')
iii. myfile = open('student.txt','r')
iv. myfile = open('student.txt')
a. only I b.both i and iv c.both iii and iv d.both i and iii
10 Which of the following statement 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
a. f = open(‘data.txt’); f.read()
b. f = open(‘data.txt’,’r’); f.read(n)
c. myfile = open(‘data.txt’); f.readline()
d. f = open(‘data.txt’); f.readlines()
20 ____________________ module is used for serializing and de-serializing any Python
object structure.
27
Twinkle twinkle little star
How I wonder what you are
Up above the world so high
Like a diamond in the sky
Suppose content of ‘Myfile.txt’ is: What will be the output of the following code?
f = open(“Myfile.txt”)
data=f.readline()
data=f.read()
print(data)
f.close()
(a) Twinkle twinkle little star (b) How I wonder what you are
(c) Twinkle twinkle little star (d) How I wonder what you are-
How I wonder what you are Up above the world so high
Like a diamond in the sky
28 How many times does the following while loop get executed?
K=5
L=36
while K<=L:
K+=6
(a) 4 (b) 5 (c) 6. (d) 7
29 Identify the output of the following Python statements.
b = 1
for a in range(1, 10,
2): b += a + 5
print(b)
a. 59 b.51 c.36 d.39
30 What will be displayed after the execution of the following loop?
sum,last=0,10
for C in range(1,last,2):
sum=sum+1
print(sum,C)
(a) 5,10 (b) 4,9 (c) 5,9 (d) 4,10
31 Rahal is trying to read data from a binary file test.bin and store it into List L.
Consider the following code written by him.
import pickle as p
with open(‘test’,’rb’) as f:
#statement 1
Identify the missing code in Statement 1.
(a) f=p.load(L) (b) p=p.load(L) (c) L=p.load(f) (d) f=L.load(p)
a. 5 b. 2 c. 4 d.7
34 What will be the output of the following code?
value = 50
def display(N):
global value
value = 35
if N%7==0:
value = value +
N else:
value = value -
N print(value, end="#")
display(20)
print(value)
Suppose root directory (School) and present working directory are the same. What will
be the absolute path of the file Syllabus.jpg?
a. School/syllabus.jpg b. School/Academics/syllabus.jpg
c.School/Academics/../syllabus.jpg d. School/Examination/syllabus.jpg
41 Write a method/function DISPLAYWORDS() in python to read lines from a text file
STORY.TXT, and display those words, which are less than 4 characters.
My first book was Me and My Family. It gave me chance to be Known to the world.
a.11 b. 14 c. 12 d. 10
42
45 When the function ABLINES() is executed, it read contents from a text file
LINES.TXT, to display those lines, which are either starting with an alphabet ‘A’ or
starting with alphabet ‘B’.
def ABLINES():
file=open(‘LINES.TXT’,’r’)
lines = file.readlines()
for w in lines:
if___
print (w)
file.close()
Select the appropriate statement to fill the statement 1.
(i) w[0]= =”A” or w[0]= =”B” (ii) w[0] in [“A”,”B”]
(iii) w[0]= =”A” and w[0]= =”B” (iv) w[0]= =”A”,”B”
(a) (i) and (ii) (b) (ii) and (iv) (c) (i) and (iv) (d) (ii) and (iii)
46 EOL stands for________
a. End of line b.End of list c. end of loop d. none of these
53 Which function to be used in Statement-4 to read the data from a csv file.
(a) read() (b) readline() (c) readlines() (d) reader()