26. Nitish has declared a tuple T in Python as following:
T = (10, 20, 30)
Now, he wants to insert an element 40 after these three elements of T so that the tuple may contain (10, 20, 30, 40).
Which of the following statements shall Nitish write to accomplish the above task?
a) T = T + 40
b) T = T+ (40)
c) T = T + (40,)
d) Nitish cannot insert 40 into the tuple since Tuples are immutable
27. Suppose the content of a text file Notes.txt is:
"The way to get started is to quit talking and begin doing"
What will be the output of the following Python code?
F = open ("Notes.txt")
F.seek (29)
S=F.read ()
print (S)
a) The way to get started is to
b) quit talking and begin doing
c) The way to get started is to quit talking and begin doing
d) gniod nigeb dna gniklat tiuq ot si detrats teg ot yaw ehT
28. Identify the output of the following Python statements
S = "GOOD MORNING"
print (S.capitalize (),S.title () ,end=" ! ")
a) GOOD MORNING!Good morning
b) Good Morning!Good morning
c) Good morning! Good Morning!
d) God morning Good Morning!
29. Identify the output of the following Python statements
L = []
for i in range (4):
L.append (2*i+1)
print (L[::-1])
a) [7,5,3,1]
b) [9,7,5,3]
c) [4,3,2,1]
d) [1,2,3,4]
30. Identify the output of the following Python statements:
D={}
T= ("ZEESHAN", "NISHANT", "GURMEET", "LISA")
for i in range (1, 5):
D[i]=T[i-1]
print (D)
a) {"ZEESHAN", "NISHANT", "GURMEET","LISA"}
b) "ZEESHAN", "NISHANT", " GURMEET","LISA"
c) {[1, "ZEESHAN"],[2, "NISHANT"], [3, "GURMEET"], [4," LISA" ]}
d) {1:"ZEESHAN" ,2:"NISHANT" ,3:"GURMEET" , 4:"LISA"}
31. Identify the output of the following Python statements
L1, L2= [10, 15, 20, 25], []
for i in range (len (L1)) :
L2. insert( i,L1.pop ())
print (LI, L2, sep="&")
a) [] & [25, 20, 15, 10]
b) [10, 15, 20, 25] & [25, 20, 15, 10]
c) [10, 15, 20, 25] & [10, 15, 20, 25]
d) [25, 20, 15, 10] & []
32. Which of the following Python modules is imported to store and retrieve objects using the process of serialization and deserialization?
a) csv
b) binary
c) math
d) pickle
33. Which of the following function is used with the csv module in Python to read the contents of a csv file into an object?
a) readrow()
b) readrows()
c) reader()
d) load()
34. What will be the output of the following Python code?
S="WELCOME"
def Change (T) :
T="HELLO"
print (T, end='@')
Change (S)
print (S)
a) WELCOME@HELLO
b) HELLO@HELLO
c) HELLO@WELCOME
d) WELCOME@WELCOME
35. Identify the correct possible output for the following Python code :
import random
for N in range (2,5,2) :
Print (random.randrange (1,N) ,end="#")
a) 1#3#5#
b) 2#3#
c) 1#4#
d) 1#3#
36. What will be the output of the following Python code ?
def FunStr (S)
T=""
for i in S :
if i.isdigit () :
T=T+i
return T
X = "PYTHON 3.9"
Y = FunStr (X)
print (X, Y, sep="*")
a) PYTHON 3.9
b) PYTHON 3.9*3.9
c) PYTHON 3.9*39
d) Error
37. What will be the output of the following Python code?
v = 50
def Change (N) :
global V
V, N = N, V
print (V, N, sep="#",end="@")
Change (20)
print (V)
a) 20#50@20
b) 50@20#50
c) 50#50#50
d) 20@50#20
38. Which of the following option can be the output for the following Python code?
L1=[10,20,30,20,10]
L2=[]
for i in L1:
if i not in L2:
L2.append(i)
print (L1, L2,sep="&")
a) [10,20,30,20,10]&[10,20,30,20,10]
b) [10,20,30,20,10]&[10,20,30,20,10]&
c) [10,20,30,20,10]&[30,20,10]
d) [10,20,30,20,10]&[10,20,30]
39. What is the output of the following Python code ?
def ListChange () :
for i in range (len (L)):
if L[i]%2 == 0 :
L[i]=L[i]*2
if L[i]%3 == 0 :
L[i]=L[i]*3
else
L[i]=L[i]*5
L = [2,6,9,10]
ListChange ()
for i in L:
print (i,end="#")
a) 4#12#27#20#
b) 6#18#27#50#
c) 20#36#27#100#
d) Error
40. Suppose the content of a text file "Rhymes.txt" is as follows
Jack & Jill
went up the hill
What will be the output of the following Python code ?
F = open ("Rhymes.txt")
L = F.readlines ()
for i in L:
S=i.split()
print (len (S) ,end="#")
a) 2#4#
b) 3#4#
c) 2#
d) 7#
41. Identify the output of the following Python code:
D={1:"One", 2:"Two", 3: "Three"}
L=[]
for K,V in D. items ():
if V[0]=="T":
L.append (K)
print (L)
a) [1,2,3]
b) ["One", "Two", "Three"]
c) [2,3]
d) ["Two", "Three"]
42. Suppose the content of "Rhymes.txt" is:
Baa baa black sheep
have you any wool?
What will be the output of the following Python code?
F = open ("Rhymes.txt")
S = F.read ()
L=S.split ()
for i in L:
if len (i) %3 != 0 :
print (i, end= " ")
a) Baa baa you any
b) black have wool?
c) black sheep, have wool?
d) Error
43. Suppose the content of "Rhymes.txt" is
One, two, three, four, five
Once. I caught a fish alive.
What will be the output of the following Python code ?
F = open ("Rhymes.txt")
S = F.read ()
print (S.count('e',20))
a) 20
b) 1
c) 3
d) 6
44. What will be the output of the following Python code?
V = 25
def Fun (Ch) :
V=50
print (V, end=Ch)
V *= 2
print (V, end=Ch)
print (V, end="*")
Fun ("!")
print (V)
a) 25*50!100!25
b) 50*100!100!100
c) 25*50!100!100
d) Error
45. Suppose the content of "Rhymes.txt" is
Good Morning Madam
What will be the output of the following Python code?
F = open ("Rhymes.txt")
L = F.read ().split ()
for W in L:
if W.lower () == W[::-1].lower ():
print (W)
a) Good
b) Morning
c) Madam
d) Error
46. Suppose the content of "Rhymes.txt" is
Hickory Dickory Dock
The mouse went up the clock
What will be the output of the following Python code?
F = open ("Rhymes. txt")
L = F. readlines ()
X = ["the", "ock"]
for i in L:
for W in i.split () :
if W in X:
print (W, end = "*")
a) the*
b) Dock*The*the*clock*
c) Dock*the*clock*
d) Error
47. Consider the following directory structure.
Suppose the present working directory is MyCompany. What will be the relative path of the file Transactions.Dat?
a) MyCompany/Transactions.Dat
b) MyCompany/Accounts/Transactions.Dat
c) Accounts/Transactions.Dat
d) ../Transactions.Dat
48. What will be the output of the following Python code?
S="UVW" ;L=[10,20,30] ;D={}
N=len (S)
for I in range (N) :
D[L[I] = s[]
for K,V in D.items () :
print (K,V, sep="*" ,end=",")
a) U*10,V*20,W*30,
b) 10*U, 20*V,30*W,
c) 10,20,30,U*V*W*
d) Error
49. What will be the output of the following Python code?
L = [10, 20]
L1=[30, 40]
L2=[50, 60]
L.append (L1)
L.extend (L2)
print (L)
a) [60, 50, 40, 30, 20, 10]
b) [10, 20, 30, 40, 50, 60]
c) [10, 20, 30, 40, [50, 60]]
d) [10, 20, [30, 40], 50, 60]