PA 2 Computer Science 12 Set A
PA 2 Computer Science 12 Set A
PERIODIC ASSESSMENT 2
SESSION: 2021-22
SUBJECT: COMPUTER SCIENCE
SUBJECT CODE: 083
Class: XII (SET A)
Name of Student: Max.Marks:35
Day & Date: Saturday,25 September 2021 Duration: 90 Minutes
Section-A
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this
section. Choose the best possible option
Section-A Mark s
1
Consider a list L = [5, 10, 15, 20], which of the following will result in an error:-
1 a) L[0] += 3 b) L += 3 c) L *= 3 d) L[1] = 45
1
Find the operator which cannot be used with a string in Python from the following:-
2 a) // b) * c) + d) in
1
Consider a tuple in python named Months = (‘Jul’, ‘Aug’, ‘Sep’). Identify the invalid statement(s) from the
3 given below statements:-
a)S = Months[0] b)print(Months[2])
c)Months[1] = ‘Oct’ d)LIST1 =list(Months)
1
4 Functions that do not return any value are known as:-
a)Fruitful functions b)Void functions
c)Standard python functions d)User-defined functions
1
5 Which function of dictionary return both key and value?
a)item b)keyvalue
c)items d)key value
1
6 Which of the following is a wrong way of defining a function:-
a)def f(x=10, y=20, z=30) b)def f(x, y, z)
c)def f(x=10, y, z) d)def f(x, y=20, z=30)
1
7 A void function also returns a value to its caller.
a) None
b) float
c) int
d) string
1
8 The file mode is used when user want to write data into binary file.
a. rb
b. wb
c. r+
d. w+
1
9 Rohan wants to drive a car but He is unable to drive because his age is below 18. A python code is written
to check his age .identify it is correct or incorrect.
Age=input(“enter age:”)
if age<=18:
print(“you are not eligible””)
a)Correct b)Incorrect
c) Can’t say d) Ambiguous
1
10 TSV stands for
a)TAB segregated Values b)TABLE Separated Values
c)TAB Separated Values d)TABLE Segregated values
1
11 The process of converting the structure to a byte stream before writing to the file is known as .
a. Pickling
b. Unpickling
c. Dump
d. load
1
12 What is the default mode of opening a file in python?
a)read b)write c)append d)read and write
1
13 Which of the following expressions is an example of type casting?
a)4.0+float(6) b)5.3+6.3 c)5.0+3 d)None of these
In which of the following flie modes, the existing data of file will not be lost? 1
15 a)wb+ b)wb c)rb d)w+
16 What is the output of the following Python Code; Select any one of the following options?
import random
print(int(random.random()*5)
a) Generate any number between 0 to 4(including both)
b) Generate any number between 0 To 5(including both)
c) None of Above
d) Ambiguous
Which of the following statement opens a binary file record.bin in write mode and writes
data from a list lst1 = [1,2,3,4] on the binary file?
17
a. with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)
b. with open('record.bin','wb') as myfile:
pickle.dump(myfile,lst1)
c. with open('record.bin','wb+') as myfile:
pickle.dump(myfile,lst1)
d. with open('record.bin','ab') as myfile:
pickle.dump(myfile,lst1)
Which of the given argument types can be skipped from a function call:
20 a Positional argument
b Keyword argument
c Named argument
d Default argument
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.
1
What will be the output after the following
26 statements?
a = [0, 1, 2, 3]
del a[:]
print(a)
a)None b)[] c)[0, 1, 2, 3] d)NameError
Partition function return 1
27 A List
B Tuple
C String
D Dictionary
What will the following code produce? 1
28 T=[‘kvs’,’rpr’]
T1=range(len(T))
for i in T1:
T[i]=T[i].upper()
print(T)
a)[‘KVS’,’RPR’]
b)[‘kvs’,’rpr’]
c)[‘Kvs’,’Rpr’]
d) Error
What is the name given to area of memory, where the system stores the parameters and a local variable of a 1
29 function call
a heap
b Storage area
c Stack
d Array
1
Identify the output of the following Python statements.
30 x = 2
while x < 9:
print(x, end='')
x=x+1
a. 12345678
b. 123456789
c. 2345678
d. 23456789
When you open a file for writing, if the file does not exist, an error occurs. 1
31 a True
b False
c can’t say
d None of above
32 The relative path for a file always remains same even after changing the directory. 1
a True
b False
c Can’t say
D None of Above
33 The value of the expressions 4/(3*(4-2)) and 4/3*(4-2) is the same 1
a True
b False
c Can’t say
d None of Above
34 The command to merge the dictionary Book with Library the command would be: 1
a) d=Book+Library b) print(Book+Library)
c)Book.update(Library) d)Library.update(Book)
35 find function in string return when substring not found in main string 1
a Exception
b -1
c valueError
d None of Above
36 Find and write the output of the following python code: 1
a=10
def call():
global a
a=15
b=20
print(a)
call()
a)25 b)35 c)15 d)10
37 What will be the output of the following code?
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())
a. 100 200
b. 150 300
c. 250 75
d. 250 300
Raghav is trying to write a tuple tup1 = (1,2,3,4,5) on a binary file test.bin. Consider the 1
38
following code written by him.
import pickle
tup1 = (1,2,3,4,5)
myfile = open("test.bin",'wb')
pickle. #Statement 1
myfile.close()
Identify the missing code in Statement 1.
a. dump(myfile,tup1)
b. dump(tup1, myfile)
c. write(tup1,myfile)
d. load(myfile,tup1)
.
1
39 if a = [5,4,3,2,2,2,1], evaluation of the expression a [ a [ a [ a [ 2 ] + 1 ] ] ]:
a)3 b)4 c)5 d)2
1
What is the output of the following program :
40 print( 0.1 + 0.2 == 0.3)
a)True b)False c)Machine Dependent d)Error
1
What will be the output after the following statements?
41 x=0
y=4
while x + y < 10:
print(x, end=' ')
x += 2
a)0 2 4 6 b)0 2 4 c)0 2 d)0 2 4 8
42 apple =’red’ 1
def fruit():
pineapple=’green’
a. Delhi#Mumbai#Chennai#Kolkata#
b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi#
d. Mumbai# Mumbai #Chennai # Mumbai
Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.
Rohit, a student of class 12th, is learning CSV File Module in Python. During
examination, he has been assigned an incomplete python code (shown below) to create
a CSV File 'Student.csv' (content shown below). Help him in completing the code which
creates the desired CSV File.
1,AKSHAY,XII, A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A
Incomplete Code
import #Statement-1
fh = open( , , newline='') #Statement-2
stuwriter = csv. #Statement-3
data = [ ]
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
class = input("Enter Class : ")
section = input("Enter section : ")
rec = [ ] #Statement-4
data.append(rec) # Statement 5
stuwriter. (data) #Statement-6
fh.close()
Answer any four of the following questions.
50 Identify the suitable code for blank space in line marked as Statement-1 1
a) csv file b) CSV c) csv d) Csv
51 Identify the missing code for blank space in line marked as Statement-2? 1
a) "School.csv","w" b) "Student.csv","w" c) "Student.csv","r" d)
"School.csv","r"
52 Choose the function name (with argument) that should be used in the 1
blank space of line marked as Statement-3
a) reader(fh) b) reader(MyFile) c) writer(fh) d) writer(MyFile)
53 Identify the suitable code for blank space in line marked as Statement-4. 1
a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
b) ROLL_NO, NAME, CLASS, SECTION
c) 'roll_no','name','Class','section'
d) roll_no,name,Class,section
54 Identify the suitable code for blank space in the line marked as Statement-5. 1
a) data
b) record
c) rec
d) insert
55 Choose the function name that should be used in the blank space of line marked as
Statement-6 to create the desired CSV File?
a) dump()
b) load()
c) writerows()
d) writerow()
9|Page