You are on page 1of 12

Toc H Public School, Vyttila

III PERIODIC ASSESSMENT, October 2021


Class XII - 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.

Section-A
This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section.
Choose the best possible option.

1. A _____________ is a sequence of one or more characters used to provide a name for a given
program element.

a. Identifier
b. Variable
c. String
d. Character
2. The functionality of seek() function is :

a. sets the file’s current position at the offset


b. sets the file’s previous position at the offset
c. sets the file’s current position within the file
d. None of the above
3. Which of the following is not a valid mode to open a file.

a. ab
b. r+
c. w+
d. rw
4. What might be the output of the following code :
A = ("hello") * 3
print(A)

a. Operator Error
b. ('hello','hello','hello')
c. 'hellohellohello'
d. None of these
Page 1 of 12
5. The ________ function returns Boolean True value if all the keys in the dictionary are True else
returns False.

a. all()
b. sorted()
c. len()
d. any()
6. Predict the output of the following code :
>>> dic = {}
>>> dic.fromkeys([1,2,3], "check")

a. Syntax error
b. {1: 'check', 2: 'check', 3: 'check'}
c. 'check'
d. {1:None, 2:None, 3:None}
7. The readline() method returns

a. str
b. a list of lines
c. a list of single characters
d. a list of integers
8. Assume tuple_1 = (7,8,9,10,11,12,13) then the output of tuple_1[1:-1] is :

a. Error
b. (8,9,10,11,12)
c. [8,9,10,11,12]
d. None
9. Infer the output of the following code :

count = {}
count[(1, 2, 4)] = 5
count[(4, 2, 1)] = 7
count[(1, 2)] = 6
count[(4, 2, 1)] = 2
tot = 0
for i in count:
tot = tot + count[i]
print(len(count)+tot)

a. 25
b. 17
c. 16
d. Error
10. The syntax to write to a CSV file is :

a. CSV.DictWriter(filehandler)
b. CSV.reader(filehandler)
c. CSV.writer(filehandler)
Page 2 of 12
d. CSV.write(filehandler)
11. What will be the output of the following code snippet ?

numbers = {}
letters = {}
comb = {}
numbers[1] = 56
numbers[3] = 7
letters[4] = "B"
comb["Numbers"] = numbers
comb["Letters"] = letters
print(comb)

a. Nested dictionary cannot occur


b. 'Numbers': {1: 56, 3: 7}
c. {'Numbers': {1: 56}, 'Letters': {4: 'B'}}
d. {'Numbers': {1: 56, 3: 7}, 'Letters': {4: 'B'}}
12. Assume air_force = ("f15", "f22a", "f35a"). Which of the following is incorrect ?

a. print(air_force[2])
b. air_force[2] = 42
c. print(max(air_force))
d. print(len(air_force))
13. The method that returns the value for the key present in the dictionary and if the key is not
present then it inserts the key with default value into the dictionary.

a. update()
b. fromkeys()
c. setdefault()
d. get()
14. What will be the output of the following ?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
print(data[1][0][0])

a. 1
b. 2
c. 4
d. 5
15. Assuming b to be a dictionary, what does any(b) do ?

a. Returns True if any key of the dictionary is True.


b. Returns False if dictionary is empty.
c. Returns True if all keys of the dictionary are True.
d. Method any() doesn’t exist for dictionary.
16. Predict the output of the following code :

for i in range(5):
with open("data.txt", "w") as f:
Page 3 of 12
if i > 0:
break
print(f.closed)

a. True
b. False
c. None
d. Error
17. What is the data type of (3) ?

a. Tuple
b. List
c. None
d. Integer
18. Assume dic is a dictionary with some key:value pairs. What does dic.popitem() do ?

a. Removes an arbitrary key:value pair


b. Removes all the key:value pairs
c. Removes the key:value pair for the key given as an argument
d. Invalid method
19. What is the output of the following piece of code?

s="a@b@c@d"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)

a) [‘a’,’b’,’c’,’d’]
[‘a’,’b’,’c’,’d’]

b) [‘a’,’@’,’b’,’@’,’c’,’@’,’d’]
[‘a’,’b’,’c’,’d’]

c) [‘a’,’@’,’b@c@d’]
[‘a’,’b’,’c’,’d’]

d) [‘a’,’@’,’b@c@d’]
[‘a’,’@’,’b’,’@’,’c’,’@’,’d’]

20. Gauge the output of the following code.


demo = {1: 'A', 2: 'B', 3: 'C'}
del demo[1]
demo[1] = 'D'
del demo[2]
print(len(demo))

a. 0
b. 2
Page 4 of 12
c. Error
d. 1
21. Which of the following statements are true ?

a. When you open a file for reading in ‘r’ mode, if the file does not exist, an error
occurs
b. When you open a file for writing in ‘w’ mode, if the file does not exist, a new
file is created
c. When you open a file for writing in ‘w’ mode, if the file exists, the existing file
is overwritten with the new file
d. All of the mentioned
22. Guess the output of the following code.
grades = {90: "S", 80: "A"}
del grades

a. Method del doesn’t exist for the dictionary.


b. del deletes the values in the dictionary.
c. del deletes the entire dictionary.
d. del deletes the keys in the dictionary.
23. For the statement given below :
example = "\t\ntweet\n"

The output for the expression example.strip() is :

a. \t\ntweet\n
b. \t\ntweet
c. tweet\n
d. 'tweet'
24. Which of the following cannot be used as a key in Python dictionaries ?

a. Strings
b. Lists
c. Tuples
d. Numerical values
25. What is the output of the following code ?

def change(var, lst):


var = 1
lst[0] = 44
k=3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)

a) 3
[44, 2, 3]
b) 1
[1,2,3]
Page 5 of 12
c) 3
[1,2,3]
d) 1
[44,2,3]

Section-B
This section consists of 24 Questions (26 to 49). Attempt any 20 questions.

26. Choose the name of missing function :

file1=open("notes.txt","a")
ch=input("enter the text")
file1.________(ch+"\n")
file1.close()

(i) writelines
(ii) write
(iii) read
(iv) append

27. Given below a program to found the occurrence of word “To” in a file notes.txt. Which function
should be used to read the file word by word ?

count=0
file1=open("notes.txt","r")
s=file1.read()
s1=_____________
for i in s1:
if(i==ch):
count+=1
print(ch," word exists ", count, " number of times")

(i) s.read(10)
(ii) s. split()
(iii) s.index()
(iv) s.readline()

28. Which types of files stores information in the form of a stream of ASCII or Unicode Characters
?

(i) Binary Files


(ii) Both Text Files and CSV Files
(iii) Only Text files
(iv) Only CSV Files

29. The readlines() method returns :

(i) String
(ii) A List of integers
Page 6 of 12
(iii) A list of characters
(iv) A List of Lines

30. Another name of file object is _______

(i) File handle


(ii) File name
(iii) No another name
(iv) File

31. What error is returned by following statement, if file “try.txt” does not exist ?
f = open(“try.txt”)

(i) Not found


(ii) FileNotFoundError
(iii) File does not exist
(iv) No error

32. In text file each line is terminated by a special character called _______

(i) EOL
(ii) END
(iii) Full stop
(iv) EOF

33. Which of the following functions do you use to write data in the binary format ?

A. write
B. load
C. dump
D. send

34. Data=F.read(10).
Which of the following statement is True regarding variable Data :

(i) Data contains list of 10 lines


(ii) Data contain list of 10 characters
(iii) Data contains string of 10 characters
(iv) Data contains integer value 10

35. How many elements are in m ?


m = [[x, y] for x in range(0, 4) for y in range(0, 4)]

a) 8
b) 12
c) 16
d) 32

Page 7 of 12
36. Name the function to read from CSV file :

a. read()
b. csv.reader()
c. csv.read()
d. reader()

37. In which file, no delimiters are used for line and no translations occur ?

a. Text file
b. Binary file
c. csv file
d. None of the above

38. What is the output of the following ?


print('cd'.partition('cd'))

a) (‘cd’)
b) (”)
c) (‘cd’, ”, ”)
d) (”, ‘cd’, ”)

39. Write the output of the following :


print((range(5)))

a) range(0, 5)
b) 0, 1, 2, 3, 4
c) [0, 1, 2, 3, 4]
d) None

40. Write the output of the following :


print(min("Hell","Hello","he"))

a) Hell
b) he
c) Hello
d) Error

41. What type of error is returned by following statement ?


print(int("a"))

a) Syntax Error
b) Value Error
c) Type Error

42. Write the output of the following :


print(float())

a) 1.0
Page 8 of 12
b) 0.0
c) Any floating point number
d) zero

43. Observe the code carefully and write answer of questions given below :
a=10
b=12
def change():
a=9
global b
b=7
print(a,b)
y=b
change()
x=a
z=b
what is the output of the above program ?

a) 9 7
b) 10 7
c) 10 12
d) None of the above

44. What will be the output ?

def increment_items(L, increment):


i=0
while i < len(L):
L[i] = L[i] + increment
i=i+1

values = [1, 2, 3]
print(increment_items(values, 2))
print(values)

a) None
[3, 4, 5]
b) None
[1, 2, 3]
c) [3, 4, 5]
[1, 2, 3]
d) [3, 4, 5]
None

45. Observe the code carefully and write answer of questions given below :
a=10
def F():
a=5

Page 9 of 12
b=20
print(a)
print(a)
What is the output of the above code?

a) 5
b) 10
c) 20
d) None of the above

46. Which function header statement is correct :

(a) def interest (prin, time=2, rate):


(b) def interest (prin=2000, time=2, rate):
(c) def interest (prin=2000, time=2, rate)
(d) def interest (prin, time=2, rate=0.10):

47. Which of the following function calls will cause error while invoking the function header
def test(a,b)

(a ) test(10,20)
(b) test(a=10, b=20)
(c) test(a=10, b)
(d) test(10, b=20)

48. If return statement is not used inside the function, the function will return :

a) 0
b) None object
c) An arbitrary integer
d) error

49. Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of
the following methods should be used ?

a) reverse(l)
b) list(reverse[(l)])
c) reversed(l)
d) list(reversed(l))

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

Amal, a student of class 12, is learning BINARY File Module in Python. During examination, he has
been assigned an incomplete Python code (shown below) to create a Binary File ‘emp.dat'. Help
him in completing the code.

Page 10 of 12
The binary file “emp.dat” has structure (Emp_id, Emp_name, Emp_Salary). Write a function in
Python countsal() in Python that would read contents of the file “emp.dat” and display the details of
those employee whose salary is greater than 20000.

import pickle
def ____________: Line1
f = open (“emp.dat”, “________”) Line 2
n=0
try:
while True:
rec = ____________ Line 3
if rec[2] > 20000:
print(rec[0], rec[1], rec[2], sep=”\t”)
num = num + _______ Line 4
except:
f.close() Line 5

50. In above program, choose correct option for Line 1

a. countsal()
b. Countsal()
c. Sal()
d. count()

51. In above program, choose correct option for Line 2

a. ab
b. rb
c. wb
d. None of the above

52. In above program, choose correct option for Line 3

a. pickle.dump()
b. pickle.read()
c. pickle.load()
d. None of the above

53. In above program, choose correct option for Line 4

a. -1
b. 2
c. 0
d. 1

54. In above program, choose correct option for Line 5

a. f.close()
b. f.exit()
Page 11 of 12
c. f.stop()
d. None of the above

55. Will the program result in an infinite loop :


a. True
b. False

_____________________ End ________________

Page 12 of 12

You might also like