You are on page 1of 12

NAME:___________________ CLASS:___________

SECTION:__________
DELHI PUBLIC SCHOOL
----------BILASPUR----------
Periodic Assessment-II (Session 2021-22)
Date : 6 October, 2021.
th

Subject: Computer Science Maximum


Marks = 35
Class: XII Time = 90
Minutes

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
 Please check that this question paper contains 55
questions and 09 printed pages.
 Candidates are advised to read all the questions
and attempt as per guidelines.
 In the event of a candidate attempting more than
required questions, the first
questions answered by the candidate shall be evaluated.

TICK THE CORRECT ANSWER

QNo 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 is a correct file mode for text files?

1 of 9
a. r b. a
c. w+ d. All
2. A file maintains a __________ which tells the current position in the
file where writing or reading will take place.
a. line b. file pointer
c. list d. order
3. Natasha is working in Python program which is function oriented.
She is using the functions already available in python. These
functions are called:
a. User defined functions b. In-built functions
c. Sample functions d. Reusable functions
4. The value of the expressions 4/(3*(4-2)) and 4/3*(4-2) is the same.
a. Yes b. No
c. Both d. None
5. Which of the following functions do we use to write data in a binary
file?
a. writer( ) b. output( )
c. dump( ) d. send( )
6. What is the correct python code to display the last four characters of
“Digital India”
a. str[-4:] b. str[:4]
c. str[4:] d. str[-1:-4]
7. If T=(A', 10, 'B', 15), which among the following will give error:
a. T=2*T b. len(T)
c. sum(T) d. T.index(‘B’)
8. Which of the following statements correctly explain the function of
tell() method?
a. tells the current position within b. tells the name of file.
the file.
c. moves the current file position d. it changes the file position
to a different location only if allowed to do so else
returns an error
9. To add data to an existing csv file, the mode of the file should be
________.

2 of 9
a. w b. w+
c. a d. r+
10. Which of the following command is used to open a file “c:\
newfile.txt” in read and write mode both?
a. infile = open(“c:\ newfile.txt”, b. infile = open(“c:\\
“r”) newfile.txt”, “r”)
c. infile = open(file = “c:\ d. infile = open(file = “c:\\
newfile.txt”, “r+”) newfile.txt”, “r+”)
11. Which of the following statement is False regarding the opening
modes of a file?
a. When you open a file for b. When you open a file for
reading, if the file does not exist, reading, if the file does not
an error occurs. exist, the program will open an
empty file.
c. When you open a file for d. When you open a file for
writing, if the file does not exist, a writing, if the file exists, the
new file is created. existing file is overwritten with
the new file
12. To move a file pointer f, 10 bytes ahead from the current position of
file, function used is –
a. f.seek(10) b. f.seek(10,0)
c. f.seek(10,1) d. f.seek(10,2)
13. Which of the following is not a function of csv module?
a. readline() b. writerow()
c. reader() d. writer()
14. What is the use of id() function in python?
a. returns the data type of object b. returns the size of the object
c. returns the identity of object d. None of the above
15. In python arguments can be passed ___________.
a. call by value b. call by reference
c. Both A and B d. None
16. Which of the following symbol is used in Python for comments?
a. /*** b. /*
c. <!-- d. #

3 of 9
17. What is returned by
>>> math.ceil(5.5)?
a. 5 b. 6
c. 5.0 d. 6.0
18. The range(x) function will generate the series of numbers from
a. 1 to x-1 b. 0 to x-1
c. 0 to x d. 1 to x
19. Which of the following function flushes the files implicitly?
a. flush() b. close()
c. open() d. fflush()
20. What will be the correct output of the statement : >>> 4+2**2*10
a. 18 b. 80
c. 44 d. None
21. Give the output of the following code:
>>>import math
>>> math.ceil(1.03)+math.floor(1.03)
a. 3 b. -3.0
c. 3.0 d. None
22. What will be the output of the following code?
A= “Virtual Reality”
print(A.replace(‘Virtual’,’Augmented’))
a. Virtual Augmented b. Reality Augmented
c. Augmented Virtual d. Augmented Reality
23. What is the output of the program given below:
x=5
def change():
x=10
change(x)
print (‘Value of x=’, x)
a. Value of x=5 b. Value of x=15
c. Value of x=10 d. Error
24. Which of the following will give output as [23,2,9,75], if L=
[6,23,3,2,0,9,8,75]
a. print(list1[1:7:2]) b. print(list1[1:7:2])

4 of 9
c. print(list1[1:8:2]) d. print(list1[0:8:2])
25. Functions that do not return any value are known as
a. Fruitful functions b. Void functions
c. Standard python functions d. User-defined functions
Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20
questions
26. What is the maximum and minimum value of z in following
program?
import random
x = random(2,6)
y = random(1,2)
z=x+y
print(z)
a. min: 1 max: 2 b. min: 2 max: 6
c. min: 1 max: 8 d. min: 3 max: 8
27. What will be the output after the following statements?
x = 27
y=9
while x < 30 and y < 15:
x=x+1
y=y+1
print (x, y)
a. 26 11 b. 25 11
c. 30 12 d. 26 10
28. What will be the output after the following statements?
a = [0, 1, 2, 3]
del a[:]
print(a)
a. None b. []
c. [0, 1, 2, 3] d. NameError
29. What will the following code produce?
T=[‘dps’,’bsp’]
T1=range(len(T))

5 of 9
for i in T1:
T[i]=T[i].upper()
print(T)

a. [‘DPS’, ‘BSP’] b. [‘dps’, ‘bsp’]


c. [‘Dps’, ‘Bsp’] d. Error
30. Find and write the output of the following python code:
a=10
def Sample():
global a
a=15
Sample()
print(a)
a. 25 b. 35
c. 15 d. 10
31. What will be the Output for the following code –
Language=["C", "C++", "JAVA", "Python", "VB", "BASIC",
"FORTRAN"]
del Language[4]
Language.remove("JAVA")
Language.pop(3)
print(Language)
a. ['C', 'C++', 'VB', 'FORTRAN'] b. ['C', 'C++', 'Python',
'FORTRAN']
c. ['C', 'C++', 'BASIC', d. ['C', 'C++', 'Python', 'BASIC']
'FORTRAN']
32. 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)
33. Which type of error will occur when the following code is executed?
>>>print(‘Cloud’ * ‘Computing’)
a. Syntax Error b. Type Error
c. Name Error d. Value Error
34. Consider the tuple in python named T= (1,2,3).

6 of 9
What will be the value of D, if-
>>> D=T*2
a. (2,4,6) b. (1,2,3,1,2,3)
c. (1,1,2,2,3,3) d. Error
35. Find the output of the following code –
fp = open("sample.txt", "r")
fp.read(8)
print(fp.tell())
fp.close()
a. 0 b. 7
c. 8 d. 9
36. What will be the output of the following code if content of the file
“smile.txt” is –

Smiling is infectious,
You catch it like the flu.
When someone smiled at me today,
I started smiling too.

file=open(“smile.txt”)
contents=file.readline()
print(file.read(7))
a. You catch it like flu. b. You cat
c. You catc d. No output
37. t=(1,2,[3,4,5],"Confused")
print(t[3][2])
Output will be –
a. 3 b. [3,4,5]
c. “Confused” d. n
38 Which of the following command is used to open a file “c:\temp.txt”
for writing in binary format only?
a. outfile = open(“temp.txt”, b. outfile = open(“c:\\temp.txt”,
“w”) “wb”)
c. outfile = open(“c:\temp.txt”, d. outfile = open(“emp.txt”,

7 of 9
“wb”) “wb+”)
39. To force python to write the contents of file buffer on to storage file,
Which from the following methods may be used.
a. buffer() b. close()
c. flush() d. write()
40. What is the process of converting a byte stream back to the
original structure called?
a. pickling b. append
c. extend d. unpickling
41. Observe the following code and fill the blank in statement 1.
import csv
with _________ as f: #statement1
r = csv.______(f) #statement2
for row in ______: #statement3
print(_____) #statement4
a. open("data.csv") b. f=open("data.csv")
c. Both d. None
42. Assume the content of text file, 'Doctors.txt' is:
Addvika Sharma
Akshat Sen
Priya Singh
Sana Skeikh
What will be the data type of rec?
f1 = open("Doctors.txt")
rec = f1.readlines()
f1.close()
a. String b. List
c. Tuple d. Dictionary
43.

8 of 9
Suppose root directory (Exam) and present working directory are the
same. What will be the absolute path of the file A2.DAT?

a.EXAM/PA2/A2.DAT b. EXAM/A2.DAT
c. A2.DAT d. None
44. Suppose content of 'Hobby.txt' is

Music, Programming, Reading, Travelling

What will be the output of the following code?

file1 = open("Hobby.txt")
vowel = list("aeiouAEIOU")
count=0
x = file1.read()
for y in x:
if (y in vowel):
count+=1
print(count)
file1.close()
a. 11 b. 12
c. 10 d. 13
45. Suppose content of 'Quote.txt' is

The secret of success is hard work.

What will be the output of the following code?


file = open("Quote.txt")
str = file.read()
y = str.count('the')
print(y)
file.close()

a. 1 b. 0
9 of 9
c. No output d. Error
46. Find the output of the following code:
Str="MyIndia@2021"
Temp=""
for i in range(len(Str)):
if Str[i].isupper():
Temp=Temp+ “ ”
elif Str[i].islower():
Temp=Temp+Str[i].upper()
elif Str[i].isdigit():
Temp=Temp+Str[i-1]
else:
Temp=Temp+"$"
print(Temp)
a. y ndia@2021 b.Y NDIA@2021
c. Y NDIA$$202 d. Y NDIA$@202
47. Suppose content of 'Success.txt' is

Your positive action


Combined with
Positive thinking
Results in success

What will be the output of the following code?

file = open("Success.txt")
record = file.read().partition()
print(len(record))
file.close()
a. 3 b. 10
c. 16 d. 20
48. What is the output of the following code?

def Check(a):
for i in range(len(a)):
10 of 9
if i%2 == 0:
a[i]+=5
else:
a[i] -= 3
L = [5,8,15,12]
Check(L)
for i in L:
print(i,end="-")
a. 5-8-20-9 b. 10-5-20-9
c. 10-5-20-9- d. 5-8-20-9-
49. Suppose content of 'Goals.txt' is

The Key to success is to focus on goals, not obstacles.

File=open(“Goals.txt”, “r”)
Str=File.read()
Print(File.read(10))
a. The Key to b. Error
c. obstacles d. No output

Section-C
Case Study based Questions
This section consists of 6 Questions (50 -55) Attempt any 5 questions.

Rehana is a student of class XII and learning to work with Binary files
in Python using a process known as Pickling/unpickling. Her teacher
has given her the following incomplete code, which is creating a
Binary file namely Mydata.dat and then opens, reads and displays the
content of this created file.

import ___________ #Statement-1


L=list()
for k in range(5):
L.append(k*k)
fout=open(“Sample.dat”, _____) #Statement-2
11 of 9
___________(L,fout) #Statement-3
fout.close()
fin=open(“Sample.dat”, “rb” )
mylist=____________(fin) #Statement-4
fin.____________ #Statement-5
print(mylist) #Statement-6

50. Which module should be imported in Statement-1.


a-pickle b- csv
c- file d- text
51. Which file mode to be passed to write data in file in Statement-2.
a. w+ b. w
c- wb d. a
52. What should be written in Statement-3 to write data onto the file.
a. dump() b. write()
c. pickle.dump() d. writeline()
53. Which function to be used in Statement-4 to read the data from the
file.
a. load() b. readline()
c. readlines() d. pickle.load()
54. The output after executing Statement-6 will be –
a. 0 1 4 9 16 b. 1, 4, 9, 16, 25
c. [0, 1, 4, 9, 16] d. [1, 4, 9, 16, 25]
55. Identify Statement-5 to break the link of file object and the file on the
disk.
a. flush() b. close()
c. write() d. None

==XXX==

12 of 9

You might also like