ComputerScience Term 1 2021
ComputerScience Term 1 2021
2 TAMBARAM, CHENNAI
Class: XII Session: 2021-22
Computer Science (Code 083)
Practice Test : Term-1
Maximum Marks: 35 Duration: 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.
a. T + 3 b. T * 4 c. max(T) d. print(T[2][0])
3 What will be the output of the following code?
x = ‘abcde’
i = ‘i’
while i in x :
print(i,end=’ ‘)
a. 0 b. 1 c. 2 d. 3
5 Which statement is used to retrieve the current position within the file?
def DISPLAYWORDS( ):
count=0
file=open(‘STORY.TXT','r')
line = file.read()
word = line.split()
for w in word:
if w[0]=="T" or w[0]=="t":
count=count+1
What would be the value of count if the contents of the file are
“Many of life’s failures are people who did not realize how close they were to success when they
gave up.”
a. 0 b. 2 c. 3 d. 4
9 The output of the given expression is
>>>20 * (20 / 0)
a. NameError b. TypeError c. OverflowError d. ZeroDivisionError
10 Given
employee={'salary':10000,'age':22,'name':'Mahesh'}
employee.pop('age')
print(employee)
What is output?
a. 4 b. 5 c. 6 d. 2
12 What is the significance of the tell() method?
a. used to change the position of the File Handle to a given specific position.
b. used to tell the position of the File Handle.
c. used to seek the name of the File.
d. used to change the access mode of the File.
file = open(“electricity.txt”,”r”)
try:
……..
def listchange(arr):
l=len(arr)
for a in range(l):
if(arr[a]%2==0):
arr[a]=10
else:
arr[a]=arr[a]*5
What would be the contents of ‘arr’ after execution of the function if the function call is as follows?
listchange([10,20,31,15])
a=10
def call():
global a
a=15
b=20
call()
print(a)
a=[[]]*3
a[1].append(7)
print(a)
a=list((45,)*4)
print(a)
a. 18 b. 10 c. 8 d. 5
31 What will be the output of the following code?
i=1
while True:
if i%3 == 0:
continue
i=i+1
print(i)
a. 1 b. 2 c. Error d. 2
2 3 3
Infinite loop after that
32 Rahul is trying to write a tuple t = (10,20,30,40,50) on a binary file notebook.bin. Consider the
following code written by him.
import pickle #statement 1
t = (10,20,30,40,50) #statement 2
myfile = open("notebook.bin",'w') #statement 3
pickle.dump(t, myfile) #statement 4
myfile.close()
Which of the following statement contains an error ?
a. 0.6 b. 20 c. None d. 0
34 Suppose content of 'book.txt' is:
open a book
and you will find,
people and places of every kind
open a book
and you can be
What will be the output of the following code?
f = open("book.txt", "r")
x = f.readlines()
print(x[-1])
a. open a book b. open a book c. and you can be d. be
and you will find and you can be
people and places of every kind
Find out, which line of output given below will not be expected from the program?
a. 0#1 b. 1#2 c. 2#3 d. 3#4
Which of the following function header is not correct for function call fun((1,2,3,4))?
38
a. def fun (a=1, b): b. def fun(c, d, a=1, b=1):
1234
2345
3456
4567
a. 2 b. 3 c. 4 d. 7
49 What will be the output of the following code:
tup = (1,2,[1,2],[3, 9], 6)
tup[3][1]= 4
tup[2][0]+= tup[2][0]
print(tup)
a. (1, 2, [2, 2], [3, 4], 6) b. (1, 2, (2, 2), (3, 4), 6)
c. (1, 2, [1, 4], [3, 4], 6) d. Error
Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.
Chunky is participating in a CodeChef programming contest. There he has been assigned an
incomplete python code (shown below) to create a CSV File 'Employee.csv' and display the file
content (as shown below). Help him in completing the code.
CSV File
empid, name, city
e1, Rekha, Jaipur
e2, Rohini, Udaipur
Incomplete Code
import____________ #Statement-1
f = open(____________, __________) #Statement-2
fobj = csv._________ #Statement-3
fobj.writerow(["empid","name", "city"])
fobj.writerow(["e1", "Rekha", "Jaipur"])
fobj.writerow(["e2", "Rohini", "Udaipur"])
f.____________ #Statement-4
_______ open("Employee.csv","r") as f: #Statement-5
readobj=csv._________ #Statement-6
for row in readobj:
print(row)
f.close()
50 Identify the suitable code for blank space in the line marked as Statement-1.
a. csv file
b. CSV
c. csv
d. cvs
51 Identify the missing code for blank space in line marked as Statement-2.
a) "Employee.csv","w"
b) "Employee.csv","wb"
c) "Employee.csv","r"
d) "Employee.cvs","r"
52 Choose the function name (with argument) that should be used in the blank space of line marked
as Statement-3.
a. reader(f)
b. reader(Employee)
c. writer(f)
d. writer(Employee)
53 Identify the suitable code for blank space in line marked as Statement-4.
a. reader()
b. close()
c. load()
d. dump()
54 Identify the suitable code for blank space in the line marked as Statement-5.
a. fopen
b. for
c. with
d. while
55 Choose the function name that should be used in the blank space of line marked as
Statement-6 ?
a. reader(f)
b. read()
c. readrows()
d. readlines(f)