Professional Documents
Culture Documents
General Instructions
• The question paper is divided into 3 sections – A, B and C
• Section A consists of 25 questions (1-25). Attempt any 20 questions.
• Section B consists of 24 questions (26-49). Attempt any 20 questions.
• Section C consists of 6 case study based (50-55). Attempt any 5 questions.
• All questions carry equal marks.
Q. N. Section – A
This section consists of 25 questions (1-25). Attempt any 20 questions
from this section. Choose the best possible option
1. Which of the following is a valid identifier?
(a) Match One
(b) 1Match
(c) Match#
(d) In_Match
Page 1 of 16
3. Which of the following is NOT a relational operator?
(a) !=
(b) **=
(c) ==
(d) <=
4. Which of the following parameter needs to be added with open() to avoid having
blank row after writing each record in a csv file?
(a) delimiter
(b) newline
(c) Either (a) or (b)
(d) Neither (a) nor (b)
freddy=3
while freddy!=0:
print(freddy)
print("Move to next question")
(a) 3
(b) 4
(c) Infinite
(d) Not even once
(a) True
(b) False
(c) Compilation Error
(d) None
7. What is the valid syntax to write an object onto a binary file opened in write
mode?
(a) pickle.dump(<object to be written>, <file handler>)
(b) dump.pickle(<file handler>,<object to be written>)
(c) dump.pickle(<object to be written>, <file handler>)
(d) pickle.dump(<file handler>,<object to be written>)
Page 2 of 16
_______________ object.
(a) Dictionary
(b) List
(c) String
(d) Integer
9. Consider the code given below and select the correct output. (Assume the
required modules have been imported)
myString="I am my own boss and my own creator"
print(myString.split('my'))
(a) ['I', 'am', 'my', 'own', 'boss', 'and', 'my', 'own', 'creator']
(b) ('I', 'am', 'own', 'boss', 'and', 'own', 'creator')
(c) ['I am ', ' own boss and ', ' own creator']
(d) ('I am ', 'my', ' own boss and my own creator')
(a) tag[5:]
(b) tag[-5:0]
(c) tag[0:-5]
(d) tag[-5:]
(a) PotLuck(12)
(b) PotLuck("no")
(c) PotLuck()
(d) PotLuck('no',10,20)
Choose the correct match out of the options given below with respect to the
given statement:
(i) print(L[1:12:3]) a. ['r', 'a', 'o']
(ii) print(L[-2:-5:-1]) b. []
(iii) print(L[:-10]) c. ['T', 'e', 'r', 'm', ' ']
(iv) print(L[-10:0]) d. ['e', ' ', 'P', 'b']
(a) B
(b) G
(c) 150
(d) E
(a) T+(‘ddd’)
(b) T+(‘ddd’,)
(c) T+ ‘ddd’
(d) T+(ddd,)
15. Which of the following built-in function returns the string with first letter of every
word in the string in uppercase and rest in lowercase?
(a) Sentence()
(b) sentence()
(c) Title()
(d) title()
16. Which of the following statements will delete the key value pair for key ,
”English” from the following dictionary?
Subjects={"Hindi”:111, "English":222,"Maths":3000}
Which of the following statements is True with respect to the given code?
19. Which built-in function returns the entire file content in the form of a list with
each line as one element of the list?
(a) read()
(b) readline()
(c) readlines()
(d) write()
(a) .txt
(b) .csv
(c) .py
(d) .bin
21. Which file open mode overwrites the contents of an already existing file?
(a) w
(b) ab
(c) a
(d) r
(a) wb
(b) w
(c) Compilation Error
(d) Runtime Error
Page 5 of 16
23. Which function is used to read all characters in a text file? (assume the file
object as F)
(a) F.readline()
(b) F.read()
(c) F.readall()
(d) F.readlines()
(a) Pickeling
(b) Unpickeling
(c) Objectifying
(d) Unobjectifying
Section - B
This section consists of 24 questions (25-49). Attempt any 20 questions
from this section. Choose the best possible option
26. Select the correct output for the code given below:
def exam(var1,var2=-2):
var1=var1//var2
var2+=var1
print(var1,var2,sep="@")
return var1,var2
num1=10
num2=exam(num1)
print(num1,num2,sep="@")
(a) -5@-7
10@(-5, -7)
(b) -5@-7
10@ -5 @ -7
(c) -7@-5
10@(-7, -5)
Page 6 of 16
(d) -7@-5
10@ -7 -5
27. Which of the given outputs is correct for the code given below:
import random
Cities=["Singapore","Paris","Tokyo","Delhi", "New
York","Sydney"]
option1=random.randint(2,4)
option2=random.randint(3,5)
for x in range(option1,option2+1):
print(Cities[x], end="#")
(a) 0
(b) 1
(c) 2
(d) 3
30. Observe the following code carefully and then choose the correct option to
complete Statement 1. Assume all the required modules have been imported.
L=["I01","Pencil",10,5]
with _______________________ as f: # Statement 1
Page 7 of 16
R=csv.writer(f,delimiter=',')
R.writerow(L)
(a) open("abc.txt",'r')
(b) open("abc.csv",'r')
(c) open("abc.txt",'w')
(d) open("abc.csv",'w')
(a) 0
(b) 1
(c) 2
(d) None
32. Suppose the content of text file, ‘goodManners.txt’ is : ( all sentences on a new
line)
F=open("goodManners.txt","r")
Data=F.readlines()
print(len(Data))
F.close()
(a) 2
(b) 3
(c) 4
(d) 5
Page 8 of 16
else:
points=points-N
print(points, end="^")
code(100//5**2)
print(points)
(a) 25^54
(b) 54^25
(c) 25^46
(d) 46^25
Page 9 of 16
L=L+1
print(finalString)
(a) C$*$$**I*
(b) C$$*$**I*
(c) $T**o**I*
(d) $T *o**I**
If the contents of countFile.txt is as given in the image, what will be the output of
the given program?
(a) False** 3
(b) 3** False
(c) 3** True
(d) True**3
Which of the following is the correct statement that is missing in the code
(Statement 1), if the output is 105?
(a) break
(b) jump
(c) continue
(d) pass
import pickle
__________________________ # Statement 1
T=("T1010","Sunny","Chandigarh","Nagpur",15000)
pickle.dump(T,f)
f.close()
Which of the following statements ( to complete Statement 1) will open the file,
result.dat, to add the new record at the end of the file?
(a) f.open("result.dat","ab")
(b) pickle.open("result.dat","ab")
(c) open.pickle("result.dat","ab")
(d) f=open("result.dat","ab")
Page 11 of 16
41. The program given below reads the contents of a binary file, result.dat. Out of
the options given below, which should be used for Statement 1? Assume the
required modules are already imported.
f=open("result.dat","rb")
count=0
rec=0
try:
while True:
rec=rec+1
______________________ # Statement 1
print("Record No", rec)
print(L1)
except:
print("Records Over")
f.close()
(a) L1=pickle.load(f)
(b) pickle.load(f,L1)
(c) pickle.load(L1,f)
(d) f.load(L1)
(a) AND$1
ARE$2
(b) ARE$1
AND$2
(c) ARE$1
AND$1
(d) AND$1
ARE$1
Page 12 of 16
43. Sangini was to read 4th line from the text file, try.txt. Which of the following is the
correct statement? Assume the file object is F.
(a) (5,6, 1, 2, 5, 6)
(b) (5, 6, 1, 2)
(c) (5, 6, 1)
(d) (5, 6, 1, 2, 5)
(a) 6
(b) 7
(c) 8
(d) 9
46. The following code counts the number of digits in a text file, digits.txt. Select the
correct option to complete Statement 1.
File=open("digits.txt","r")
count=0
data=File.read()
for ch in data:
if___________________: # Statement 1
count+=1
print("No of digits ", count)
File.close()
(a) ch = "0123456789"
(b) ch not in "0123456789"
Page 13 of 16
(c) ch != "0123456789"
(d) ch in "0123456789"
47. What will be the output if following statements are executed on the interpreter?
>>> import math
>>> Z=math.ceil(12.909)-math.floor(12.909)
>>> not bool(Z)
(a) 1
(b) 0
(c) True
(d) False
(a) [1,2,10,4]
(b) 32160989528761
(c) 10
(d) 32160989528771
import math
num1=divmod(25,4)
num2=int(math.fmod(15,4))
num1=num1+(num2,)
print(num1)
(a) (6, 1, 3)
(b) [6, 1, 3]
(c) (1,6, 3)
(d) [1, 6, 3]
Section – C
Case Study Based Questions
This section contains 6 questions (50-55). Attempt any 5 questions
Salman is learning to store data in a csv file through a Python program. He has
been assigned the following code which is incomplete. Help him in completing
Page 14 of 16
the code.
___________________ # Statement 1
Account1={'Acc No':1234,'Name':'Aditya','Balance':500000}
Account2={'Acc No':5678,'Name':'Geet','Balance':250000}
with open("myBank.csv",'a', newline='') as C1:
colheadings=['Acc No','Name','Balance']
wr=_____________________________ #Statement 2
________________________________ # Statement 3
wr.writerow(Account1)
wr.writerow(Account2)
with open("myBank.csv",'r') as C1:
rr=csv._______________ (C1) # Statement 4
print('Acc No','Name','Balance')
__________________ # Statement 5
print(row['Acc No'],row['Name'],row['Balance'])
50. Identify the statement ( Statement 1) to include the relevant module in the
program.
52. While executing the code for the first time, if the file does not exist, what will
happen?
(a) A syntax error will be displayed
(b) A new file will be created
(c) File will not open
(d) A runtime error will be displayed
54. Which of the following built-in functions should be used to complete Statement
Page 15 of 16
4?
(a) Reader()
(b) dictReader()
(c) reader()
(d) DictReader()
55. Out of the options given below, identify the correct loop statement to complete
Statement 5.
(a) for rr in row:
(b) for row in range(rr):
(c) for row in rr:
(d) for row in rr[0:]:
Page 16 of 16