Section A
1. Which of the following is/are character set?
(a) Alphabets
(b) Digits
(c) White space
(d) All of these
Answer
D
2. Which of the following are the most obvious kind of constants?
(a) Keywords
(b) Literals
(c) Variables
(d) Identifiers
Answer
B
3. These operators are used to make a decision on two conditions.
(a) Logical
(b) Arithmetic
(c) Relational
(d) Assignment
Answer
A
4. String literals in Python are enclosed by ………… .
(a) double quotes
(b) single quotes
(c) Both (a) and (b)
(d) None of these
Answer
C
5. Which index number is used to represent last character of string?
(a) − 1
(b) 1
(c) 0
(d) n − 1
Answer
A
6. ……… operator checks whether the left value is greater than the one on the right.
(a) Greater than or equal to
(b) Greater than
(c) Less than or equal to
(d) Less than
Answer
B
7. file. mode attribute is used to
(a) store access mode
(b) traverse mode
(c) return access mode
(d) All of these
Answer
C
8. This method is used to write a string into the file.
(a) writelines()
(b) write()
(c) writerow()
(d) writer()
Answer
B
9. Which of the following is/are used as line termination for readline()?
(a) ‘\n’
(b) EOF
(c) Either (a) or (b)
(d) None of these
Answer
C
10. Serialization process is also called
(a) pickling
(b) unpickling
(c) dump() method
(d) load() method
Answer
A
11. This character is used in CSV file.
(a) rb
(b) wb
(c) rb +
(d) x
Answer
D
12. Which of the following is related to working directory?
(a) Relative
(b) Absolute
(c) Both (a) and (b)
(d) None of these
Answer
A
13. The def keyword is followed by the function name and
(a) parameter
(b) argument
(c) parenthesis
(d) classes
Answer
C
14. To add a new element to a list, which command will we use?
(a) list1.add(8)
(b) list1.append(8)
(c) list1.addLast(8)
(d) list1.addEnd(8)
Answer
B
15. What will be the output of the following Python code snippet?
d = {“Neha”:140, “Paras”:145}
print(list(d.keys())
(a) [“Neha”, “Paras”]
(b) [“Neha”:140, “Paras”:145]
(c) (“Neha”, “Paras”)
(d) (“Neha”:140, “Paras”:145)
Answer
A
16. If a=(11,12,13,14), a[1:−1] is………
(a) (12,13)
(b) [12,13]
(c) (12,13,14)
(d) error, tuple slicing does not exist
Answer
A
17. Which one of the following has the same precedence level?
(a) Addition and Subtraction
(b) Multiplication, Division and Addition
(c) Multiplication, Division, Addition and Subtraction
(d) Addition and Multiplication
Answer
A
18. What will be the value of x in the following Python expression?
x=int(43.55+2/2)
(a) 43
(b) 44
(c) 22
(d) 23
Answer
B
19. Which of the following will run without error?
(a) round(65.8)
(b) round(1265.983,2,4)
(c) round()
(d) round(6529.123,2,l)
Answer
A
20. Which of these definitions correctly describe a module?
(a) Denoted by triple quotes for providing the specification of certain program elements
(b) Design and implementation of specific functionality to be incorporated into a program
(c) Defines the specification of how it is to be used
(d) Any program that reuses code
Answer
B
21. Which of the following is not a valid namespace?
(a) Global namespace
(b) Public namespace
(c) Built-in namespace
(d) Local namespace
Answer
B
22. What is the use of tell() method in Python?
(a) Tells you the current position within the file
(b) Tells you the end position within the file
(c) Tells you the file is opened or not
(d) None of the above
Answer
A
23. Which of the following mode will refer to binary data?
(a) r
(b) w
(c) +
(d) b
Answer
D
24. Correct syntax of file.writelines() is
(a) file.writelines(sequence)
(b) fileObject.writelines()
(c) fileObject.writelines(sequence)
(d) None of these
Answer
C
25. Which of the following is not a valid attribute of a file object (fp)?
(a) fp.name
(b) fp.closed
(c) fp.mode
(d) fp.size
Answer
D
Section B
26. Find the output of the following code.
dict = {}
a, b, c = 15, 25, 35
dict[a, b, c] = a + b – c
a, b, c = 25, 20, 40
dict[a, b, c] = a + b – c
print(dict)
(a) {(15, 25, 35) : 5, (25, 20, 40) : 5}
(b) {(15, 25, 35), (25, 20, 40)}
(c) {15, 25, 35, 25, 20, 40}
(d) Error
Answer
A
27. What will be printed on the console by the below code?
x, y, z, k, j = 9, 7, 2, 2, 1
m = 5
if (x > y):
if (y > z and y > k):
m = m – 1
else:
k = k + 1
else:
j = j + 1
print(“m =”, m)
print(“k =”, k)
print(“j =”, j)
(a) m = 2
k = 4
j = 1
(b) m = 4
k = 2
j = 1
(c) m = 1
j = 2
k = 4
(d) m = 2
k = 4
j = 3
Answer
B
28. Write the output of the following code.
number = 2
def Fun ():
number = 5
print(“Number(s):”)
print(number)
Fun()
print(number)

Answer
C
29. What will be the output of the following Python code?
i = 1
while True:
if i%5 == 0:
break
print(i)
i += 1

Answer
A
30. What will be the output of the following Python code?
str1 = “be honest”
for i in str1.split():
print(i, end=“, ”)
(a) b, e, , h, o, n, e, s, t,
(b) b, e,, h, o, n, e, s, t
(c) be, honest,
(d) Error
Answer
C
31. What will be the output of the following Python code?
a=[13,6,77]
a.append([87])
a.extend([45,67])
print(a)
(a) [13,6,77, [87], 45, 67]
(b) [13,6,77,87,45,67]
(c) [13,6,77,87,[ 45,67]]
(d) [13,6,77, [87], [45,67]]
Answer
A
32. What will be display by this file?
import os
f=‘computer.txt’
p=os.path.abspath(f)
print(p)
(a) File name
(b) Complete path
(c) File name with directory name
(d) File name with folder name
Answer
B
33. What will be the output of following code?
def count():
v=0
f=open(“para.txt”, “r”)
N=f.read()
M=N.split()
for i in M:
if (i!=“a” or i!= “e” or i!=“i” or i!=“o” or i!=“u”):
print(i)
v=v+1
f.close()
print(v)
If content of file ‘‘para.txt’’ is
(a) 11
(b) 7
(c) 18
(d) 19
Answer
A
34. What will be the output of following code?
def Readfile():
i=open(“Employee.dat”,“rb+”)
x=i.readline()
while(x):
l=x.split(‘:’)
if(20000>=float(l[2])<=40000):
print(x)
x=i.readline()
(a) Display details of employees who are earning between 20000 and 40000 (both are exclusive)
(b) Display details of employees who are earning between 20000 and 40000 (both are inclusive)
(c) Display details of employees who are earning between 20000 and 40000 (only 20000 inclusive)
(d) Display details of employees who are earning between 20000 and 40000 (only 40000 inclusive)
Answer
B
35. Evaluate the following expression and identify the correct answer.
15 − (2 + 7) * 5 + 3 * *2 * 6 − 4 + 2
(a) 18
(b) 20
(c) 22
(d) 35
Answer
C
36. What will be the output of the following Python code snippet?
a = ‘hello’
for i in range(len(a)):
a[i].upper()
print(a)
(a) hello
(b) HELLO
(c) Hello
(d) Error
Answer
A
37. What will be the output of the following Python code?
tup1=[(56, 89),(36,66),(88, 69)]
s = tup1.sort()
print(s)
(a) [(36, 66), (56, 89), (88, 69)]
(b) [(56, 89),(36,66),(88, 69)]
(c) Error because tuples are immutable
(d) Error because tuple has no sort attribute
Answer
A
38. What will be the output of the following Python code?
def sum(*args):
‘‘‘Function returns the sum of all values’’’
r = 0
for i in args:
r += i
return r
print(sum._doc)
print(sum(5, 8, 3))
print(sum(2, 6, 3, 4, 1))

Answer
A
39. What will be the output of the following Python code?
x=2
def test():
global x
x=x+1
test()
print(x)
(a) 2
(b) 1
(c) 0
(d) 3
Answer
A
40. What will be the output of the following Python code?
i = 0
while i < 10:
print(i)
i += 2
if i == 8:
break
else:
print(0)

Answer
A
41. What is the output of the following code snippet?
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print(AR[K],end=“#”)
(a) 10#40#70#
(b) 30#40#50#
(c) 50#60#70#
(d) 40#50#70#
Answer
B
42. What is the output of the following code snippet?
To=5
for K in range(O,To) :
if K%4==0:
print (K*4)
else:
print (K+3)

Answer
C
43. Find and write the output of the following Python code.
a=10
def call():
global a
a=15
b=20
print(a)
call()
(a) 20
(b) 35
(c) 10
(d) 15
Answer
D
44. What will be the output of the following code?
def DISPLAYWORDS():
c=O
file=open(‘STORY.TXT’,‘r’)
line = file.read()
word = line.split()
for w in word:
if len(w)<4:
print(w)
file.close()
If the content of file “Story.txt” is
(a) 9
(b) 10
(c) 19
(d) 11
Answer
A
45. What will be the output of the following Python code?
a=[18,23,69,[73]]
b=list(a)
a[3][0]=110
a[1]=34
print(b)
(a) [18,34,69,[110]]
(b) [18,23,69,[73]]
(c) [18,23,69,[110]]
(d) [18,34,69,[73]]
Answer
C
46. What will be the output of the following Python code?
list1=[9, 5, 3, 5, 4]
list1[1:2]=[7,8]
print(list1)
(a) [9,5, 3, 7, 8]
(b) [9, 7, 8, 3, 5, 4]
(c) [9,[ 7, 8], 3, 5,4]
(d) Error
Answer
B
47. What will be the output of the following Python code snippet?
dic1 = {1:‘One’, 2:‘Two’, 3:‘Three’}
del dic1[1]
dic1[1] = ‘Four’
del dic1[2]
print(len(dic1))
(a) 0
(b) 2
(c) 1
(d) Error as the key-value pair of 1:‘One’ is already deleted
Answer
B
48. What will be the output of following code?
f=open(“student.txt”,“r”)
str=f.read()
s=len(str)
print (s)
f.close()
If the content of file “student.txt” is
(a) 20
(b) 18
(c) 19
(d) 17
Answer
C
49. What will be the output of the following code?
t1=(2, 5,[1,2], 9)
t1[2][1]=11
print(t1)
(a) (2, 5, [11, 2], 9)
(b) (2, 5, [1, 2], 11)
(c) (2, 5, [1, 11], 9)
(d) Error
Answer
C
Section C
Case Study Based Questions
Riya write a program to open a file ‘status.txt’ to read each character and print the occurrence of alphabets A and N.
def countAN():
f = open(“status.txt”, “r”)
a = 0
n = 0
while ____ : # line 1
l = f.readline( )
if not l :
____ # line 2
for i in ____ : # line 3
if (i = = ‘A’ or i = = ‘a’):
a = + 1
elif (____): # line 4
n = ____ # line 5
print (“A :”, a)
print (“N :”, n)
____ . close () #line 6
50. Which condition will be satisfy in while loop in line 1 as marked?
(a) Flag
(b) False
(c) True
(d) None
Answer
C
51. Choose the correct option to fill the blank in line 2 as marked.
(a) continue
(b) break
(c) False
(d) True
Answer
B
52. Choose the correct option to fill the blank in line 3 as marked.
(a) l
(b) f
(c) n
(d) a
Answer
A
53. Which condition will be used in elif ?
(a) i == N or i == n
(b) i == ‘N’ or i == ‘n’
(c) i = ‘N’ or i = ‘n’
(d) i == ‘N’ and i == ‘n’
Answer
B
54. Which value will be assign to variable n in line 5 as marked?
(a) n − 1
(b) n + 1
(c) n
(d) n *n
Answer
B
55. Identify the missing code to close the file in line 6 as marked.
(a) l
(b) n
(c) f
(d) file
Answer
C