JAIPURIAR SCHOOL, CBSE
SENIOR SECONDARY
SANPADA, SCHOOL
NAVI MUMBAI
SESSION 2021 – 2022
(Senior Secondary School)
Session 2014 - 2015
TERM 1 PRELIM 1 BOARD EXAMINATION
Subject- Computer Science (083)
Class-XII Date: 25.10.2021
Time Allotted: 90 min. Max. Marks: 35
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.(1 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 Which one of the following is not a keyword:
A. if
B. else
C. While
D. try
2 If we want to know the current file position, which method can be applied:
A. seek()
B. tell()
C. ask()
D. position()
3 To read the remaining lines of the file from a file object infile, we use _
A. infile.read(2)
B. infile.read()
C. infile.readline()
D. infile.readlines()
4 Which is not a string out of the followings: -
A. ‘55’
B. “X.Y”
C. “Hello 1”
D. None of the above
5 .Choose the correct option with respect to Python
A. Both tuples and lists are immutable.
B. Tuples are immutable while lists are mutable.
C. Both tuples and lists are mutable.
D. Tuples are mutable while lists are immutable.
1
6 Choose invalid identifier : -
A. My-age
B. _AGE
C. 1st_Value
D. My Age
7 Suppose t = (1, 2, 4, 3), which of the following is incorrect?
A. print(t[3])
B. t[3] = 45
C. print(max(t))
D. print(len(t))
8 What is the length of the given tuple?
t1=(1,2,(3,4,5))
A. 1
B. 2
C. 3
D. 4
9 Which of the following declarations is incorrect?
A. _x = 2
B. __x = 3
C. __xyz__ = 5
D. None of these
10 Which of the following operators is the correct option for power(ab) in python?
A. a ^ b
B. a**b
C. a ^ ^ b
D. a ^ * b
11 What is printed by the following statements?
D1 = {"cat":17, "dog":6, "elephant":23, "bear":20}
print ("dog" in D1)
A. True
B. False
C. Error
D. None
12 Which of the following represents mode of both writing and reading binary format in file?
A. wb+
B. wb
C. w
D. w+
13 Which file can open in any text editor and is in human readable form?
A. Binary files
B. Video files
C. Data files
D. Text file
14. If we do not specify file mode while opening a file, the file will open in…..…mode.
A. read
B. write
C. append
D. Error occur 2
15 The _____________ method of pickle module writes data into a binary file?
A. load( )
B. dump( )
C. seek( )
D. tell( )
16 Which of the following is not a function of csv module?
A. readline()
B. writerow()
C. reader()
D. writer()
17 Choose correct answer
def fun1(num):
return num+5
print(fun1(5))
print(num)
A. Print value 10
B. Print value 5
C. Name Error
D. 25
18 Which of the following character acts as default delimiter in a csv file?
A. (colon) :
B. (hyphen) -
C. (comma) ,
D. (vertical line) |
19 Yashi wants to check whether her name is listed in Shortlisted.dat or not. Which command
she can write to open the file:
A. a=open(“Shortlisted.dat”,”rb”)
B. with open (“Shortlisted.dat’,’rb”) as a:
C. None
D. Both a and b
20 The read() method returns
A. String
B. A List of integers
C. A list of characters
D. A List of Line
21 Which of the following is not a file extension for text files?
A. .txt
B. .ini
C. .rtf
D. .DAT
22 Which of the following is not a proper file access mode?
A. append
B. read
C. write
D. close
3
23 Which of the following symbol is used in Python for single line comment?
A. /
B. /*
C. //
D. #
24 To open a file c:\scores.txt for writing, we use ____________
A. outfile = open(“c:\scores.txt”, “w”)
B. outfile = open(“c:\\scores.txt”, “w”)
C. outfile = open(file = “c:\scores.txt”, “w”)
D. outfile = open(file = “c:\\scores.txt”, “w”)
25 Which of the following parameter needs to be added with open function to avoid blank
row followed file.
A. delimiter
B. newline
C. writer,dlimiter
D. file object
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
26 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
D. 1,5,9,13
27 What will be the output for the below code snippet:
def div(lst,n):
for i in range(0,n):
if lst[i]%5==0:
lst[i]+=5
else:
lst[i]=lst[i]//2
lt=[45,20,23,54,5]
div(lt, len(lt))
for i in lt:
print(i,end=’#’)
A. 50#25#11.5#27.0#10#
B. 50#25#11#27#10#
C. 50#25#1#0#10#
D. 225#100#1#0#25#
28 Evaluate the following expression and identify the correct answer.
16 - (4 + 2) * 5 + 2**3 * 4
A. 54
B. 46
C. 18
D. 32
4
29 Given a file 'stu.txt'
my school is best in the world. i am a best student.
i like computer.
What will be the output of the following code?
myfile = open("stu.txt")
str = myfile.readlines()
lcount = len(str)
print(lcount)
myfile.close()
(A) 1
(B)2
(C) 3
(D)4
30 What will be the output when the following code is executed?
i=1
while i < 6:
print(i)
if i < 2:
break
i += 1
A. 1
B. 1 2
C. 0 1
D. 1 2 3
31 Considering the following function/method in python which read lines from a text file
“INDIA.TXT”, to find and display the occurrence of the word “India”.
Find the missing statement in following code:
def countword():
f=open("INDIA.TXT", 'r')
count=0
data=___________
word=data.split()
for i in word:
if i.lower()=='india':
count=count+1
print("no of words=",count)
f.close()
(A) f.read()
(B) f.readline()
(C) f.readlines
(D) f.write()
5
32 Consider the following code and choose correct answer
def nameage(name=”kishan”, age=20):
return age,name
t=nameage(20,”kishan”)
print(t[1])
A. kishan
B. 20
C. (kishan, 20)
D. (20,kishan)
33 To open a file Myfile.txt ,which is stored in D Drive under folder CS, for READING , we can
use
A. F=open("d:\CS\Myfile.txt","rw")
B. F=open(file="d:\CS\Myfile.txt","wr")
C. F=open(r"d:\CS\Myfile.txt","r")
D. F=open("d:\Myfolder\\Myfile.txt","w")
34 The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is
stored in the following list:
stRecord = ['Raman','A-36',[56,98,99,72,69], 78.8]
Write Python statements to retrieve 69 the from the list stRecord.
A. print(stRecord [2][4])
B. print(stRecord [2][-1])
C. print(stRecord [-2][1])
D. all of the mentioned
35 What will be the output of the following code
def fun2(name,age):
print(age,name)
func2(25,”Ramesh”)
A. age name
B. 25 Ramesh
C. Ramesh, 25
D. Error
36 Shripra is trying to write a tuple t1 = (1,2,3,4,5) on a binary file item.bin. Consider the
following code written by him.
import pickle
t 1= (1,2,3,4,5)
f = open("item.bin",'wb')
pickle._______ #Statement 1
f.close()
Identify the missing code in Statement 1.
A. dump(f,t1)
B. dump(t1, f)
C.write(t1,f)
6
D. load(f,t1)
37 What will be the output of the following code?
value = 50
def display(N): global
value value = 25
if N%7==0:
value = value + N else:
value = value - N
print(value, end="#") display(20)
print(value)
A. 50#50
B. 50#5
C. 50#30
D. 5#50#
38 Nisha wants to add new item in a binary file while keeping old data in file, which opening
mode she must use:
A. wb
B. wb+
C. ab
D. w
39 What will be the output when the following code is executed?
n = 10
sum = 0
i=1
while i <= n:
sum = sum + i
i = i+1
print("The sum is", sum)
A. 10
B. 0
C. 55
D. 11
40 Which command can we use to insert 5 at the third position in list1?
A. list1.insert(3, 5)
B. list1.insert(2, 5)
C. list1.add(3, 5)
D. list1.append(3, 5)
41 def Interest(p,c,t=2,r=0.09):
return p*t*r
Considering the above defined function which of following function call are legal.
A. Interest(p=1000,c=5)
B. Interest(r=0.05,500,3)
C. Interest(500,t=2,r=0.05)
D. Interest(c=4,r=0.12,p=5000)
7
42 Consider the code given below and Identify Which message will never be printed
def prog(name):
for x in name:
if x.isalpha():
print(“alphabet”)
elif x.isdigit():
print(“digit”)
elif x.isupper():
print(“upper”)
else:
print(“all the best”)
prog(vishal123@gmail.com)
A. alphabet
B. digit
C. upper
D. all the best
43 What is the output of below program? def
say(message, times = 1):
print(message * times , end =’ ‘) say(‘Hello and’)
say('World', 5)
A. Hello and WorldWorldWorldWorldWorld
B. Hello and World 5
C. Hello and World,World,World,World,World
D. Hello and HelloHelloHelloHelloHello
44 You have given a file 'teacher.txt'
I am a student of class XII. My best teacher is Mr. N. K. Singh. He is very nice person. He
teaches me computer science. I respect him very much. Every student love him.
What will be the output of the following code?
infile = open("teacher.txt")
xa= infile.read()
b = x.count('is')
print(b)
infile.close()
(A) 2
(B) 3
(C)4
(D)5
45 Read the code given below and answer the question:
f=open(“sample.txt”,’w’)
f.write(“Morning”)
f.close()
If the file contains “Good” before execution, what will be the contents of the file after
execution of this code?
(A) Good Morning
(B) Good
(C)Morning
(D) None of these 8
Suppose content of 'Poem.txt' is
46 His belly's getting bigger,
And his hair is turning
white.
His eyes shine and sparkle
Like the stars on Christmas
night
What will be the output of the following code?
myfile = open("Poem.txt") line_count =0
data = myfile.readlines() for line in data:
if line[0] == 'H': line_count += 1
print(line_count)
myfile.close()
A. 2
B. 3
C. 4
D. 5
47 Consider the following directory structure.
Suppose root directory (School) and present working directory are the same. What will be
the absolute path of the file Sports.jpg?
A. School/Sports.jpg
B. School/Sports/ Achievement.jpg
C. School/Sports/../ Achievement.jpg
D. School/Sports/Achievement.jpg
48 Assume the content of text file, 'student.txt' is:
Virat Kohli
MS Dhoni
R.P singh
KL Rahul
What will be the data type of data_rec?
myfile = open("Myfile.txt") data_rec =
myfile.readlines() myfile.close()
A. string
B. list
C. tuple
D. dictionary
9
49 What will be the output of the following code?
tup1 = (1,2,[1,2],3) tup1[2][1]=3.14
print(tup1)
A. (1,2,[3.14,2],3)
B. (1,2,[1,3.14],3)
C. (1,2,[1,2],3.14)
D. Error Message
Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.
Your teacher has given you a method/function FilterWords() in python which read lines
from a text file NewsLetter.TXT, and display those words, which are lesser than 4
characters.Do the needful with the following python code.
def FilterWords():
file=open('NewsLetter.TXT', '________') #Statement-1
line=file.________________ #Statement-2
word=__________________ #Statement-3
for c in _______________ : #Statement-4
if _____________ : #Statement-5
print(c)
_____________ #Statement-6
FilterWords()
50 Write mode of opening
the file in statement-1?
A. a B. ab
C. w D. r
51 Fill in the blank in statement-2 to read the data from the file.
A. File.Read() B. file.read()
C. read.lines( ) D. readlines( )
Fill in the blank in statement-3 to read data word by word.
52 A. Line.Split() B. Line.split()
C. line.split() D. split.word()
53 Fill in the blank in statement-4, which retrieve each word.
A. Line B. File
C. word D. None of the above
54 Fill in the blank in statement-5, which display the word having lesser than 4 characters.
A. len(c) ==4 B. len(c)<4
C. len()==3 D. len(4)<c
55 Fill in the blank in Statement-6 to close the file
A. file.close() B. File.Close()
C. Close() D. End() 10
11