18. What is the output of the following program?
dictionary1 = {'GFG' : 1,
'Google' : 2,
'GFG' : 3
}
print(dictionary1['GFG']);
Correct : C. 3
19. What is the output of the following program?
temp = dict()
temp['key1'] = {'key1' : 44, 'key2' : 566}
temp['key2'] = [1, 2, 3, 4]
for (key, values) in temp.items():
print(values, end = "")
Correct : B. {„key1‟: 44, „key2‟: 566}[1, 2, 3, 4]
20. What is the output of the following program?
data = [2, 3, 9]
temp = [[x for x in[data]] for x in range(3)]
print (temp)
23. What is the output of the following program?
import sys
L1 = tuple()
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)
print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
print(sys.getsizeof(L1))
Correct : C. 48 64 72 128
24. What is the output of the following program?
T = (1, 2, 3, 4, 5, 6, 7, 8)
print(T[T.index(5)], end = " ")
print(T[T[T[6]-3]-6])
Correct : B. 5 8
25. What is the output of the following program?
L = [1, 3, 5, 7, 9]
print(L.pop(-3), end = ' ')
print(L.remove(L[0]), end = ' ')
print(L)
Correct : A. 5 None [3, 7, 9]
26. What is the output of the following program?
def REVERSE(L):
L.reverse()
return(L)
def YKNJS(L):
List = list()
List.extend(REVERSE(L))
print(List)
L = [1, 3.1, 5.31, 7.531]
YKNJS(L)
Correct : B. [7.531, 5.31, 3.1, 1]
27. What is the output of the following program?
from math import sqrt
L1 = [x**2 for x in range(10)].pop()
L1 + = 19
print(sqrt(L1), end = " ")
L1 = [x**2 for x in reversed(range(10))].pop()
L1 + = 16
print(int(sqrt(L1)))
Correct : C. 10 .0 4
28. What is the output of the following program?
D = dict()
for x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7] = x[0]
print(D)
Correct : C. {0: 0, 7: 0, 1: 1, 8: 1}
29. What is the output of the following program?
D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
print(D[D[D[str(D[1])]]])
Correct : B. 3
30. What is the output of the following program?
D = dict()
for i in range (3):
for j in range(2):
D[i] = j
print(D)
Correct : B. {0: 1, 1: 1, 2: 1}
31. What is the output of the following program? from math import *
a = 2.13
b = 3.7777
c = -3.12
print(int(a), floor(b), ceil(c), fabs(c))
Correct : B. 2 3 -3 3.12
32. What is the output of the following program?
Correct : D. [0, „2‟, „3‟, „5‟, „5‟, 0]
33. What is the output of the following program?
import string
import string
Line1 = "And Then There Were None"
Line2 = "Famous In Love"
Line3 = "Famous Were The Kol And Klaus"
Line4 = Line1 + Line2 + Line3
print(string.find(Line1, 'Were'), string.count((Line4), 'And'))
Correct : C. (15, 2)
34. What is the output of the following program?
line = "What will have so will"
L = line.split('a')
for i in L:
print(i, end=' ')
Correct : B. Wh t will h ve so will
35. What is the type of each element in sys.argv?
Correct : D. string
36. What is the length of sys.argv?
Correct : B. number of arguments + 1
37. What is the output of the following code?
def foo(k):
k[0] = 1
q = [0]
foo(q)
print(q)
Correct : B. [1].
38. What is the output of the following code?
def foo(fname, val):
print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])
Correct : A. 3 1
39. What is the output of the following?
elements = [0, 1, 2]
def incr(x):
return x+1
print(list(map(elements, incr)))
Correct : C. error
40. What is the output of the following?
elements = [0, 1, 2]
def incr(x):
return x+1
print(list(map(incr, elements)))
Correct : A. [1, 2, 3].
41. What is the output of the following?
def to_upper(k):
return k.upper()
x = ['ab', 'cd']
print(list(map(to_upper, x)))
Correct : A. [„AB‟, „CD‟].
42. What is the output of the following?
x = ['ab', 'cd']
print(len(list(map(list, x))))
Correct : A. 2
43. Program code making use of a given module is called a ______ of the module.
Correct : A. Client
44. What is the output of the following piece of code?
#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)
Correct : D. There is a name clash
45. What is the output of the following program? tday=datetime.date.today()
print(tday.month())
Correct : D. 8
46. Which of the following formatting options can be used in order to add „n‟ blank spaces
after a given string „S‟?
Correct : D. print(“%-ns”%S)
47. What is the output of the following program?
f = None
for i in range (5):
with open("data.txt", "w") as f:
if i > 2:
break
print(f.closed)
Correct : A. True
48. To read the entire remaining contents of the file as a string from a file object infile, we use
Correct : B. infile.read()
49. Suppose t = (1, 2, 4, 3), which of the following is incorrect?