Review each question and reveal answers to strengthen your understanding
1 What is answer of this expression, 22 % 3 is?
✅ Correct Answer: 2
2What is the output of this expression, 3*1**3?
✅ Correct Answer: 3
3Which of the following will run without errors ?
✅ Correct Answer: 1
4 What dataype is the object below ?
L = [1, 23, 'hello', 1].
✅ Correct Answer: 1
5What does --------- 5 evaluate to?
✅ Correct Answer: 1
6What is the result of round(0.5) “ round(-0.5)?
✅ Correct Answer: 2
7What is the maximum possible length of an identifier?
✅ Correct Answer: 4
8All keywords in Python are in
✅ Correct Answer: 4
9Which of the following is an invalid statement?
✅ Correct Answer: 2
10Which of these in not a core datatype?
✅ Correct Answer: 4
11 The output of the two codes shown below is the same. State whether this statement is true or false.
bin((2**16)-1)
'{}'.format(bin((2**16)-1))
✅ Correct Answer: 1
12What is the output of the code shown below?
'The {} side {1} {2}'.format('bright', 'of', 'life')
✅ Correct Answer: 1
13 In the code shown below, which function is the decorator?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
✅ Correct Answer: 2
14What is the output of the code shown below?
def f(x):
def f1(a, b):
print("hello")
if b==0:
print("NO")
return
return f(a, b)
return f1
@f
def f(a, b):
return a%b
f(4,0)
✅ Correct Answer: 1
15What is the output of the code shown below?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
✅ Correct Answer: 4
16What is the result of the expression shown below if x=56.236?
print("%.2f"%x)
✅ Correct Answer: 2
17h of the following formatting options can be used in order to add 'n' blank spaces after a given string 'S'?
✅ Correct Answer: 2
18What is the output of the code shown?
x=3.3456789
'%f | %e | %g' %(x, x, x)
✅ Correct Answer: 4
19The output of the code shown below is:
s='{0}, {1}, and {2}'
s.format('hello', 'good', 'morning')
✅ Correct Answer: 3
20 What is the output of the code shown below?
def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))
✅ Correct Answer: 2
21What is the output when following code is executed ?
print r"
hello"
The output is
✅ Correct Answer: 2
22What is the output of the following code ?
example = "snow world"
example[3] = 's'
print example
✅ Correct Answer: 3
23What is the output of "helloÂ+1+2+3 ?
✅ Correct Answer: 3
24 What is the output of the following?
print('*', "abcdef".center(7), '*')
✅ Correct Answer: 2
25 What is the output of the following?
print("xyyzxyzxzxyy".count('xyy', 2, 11))
✅ Correct Answer: 2
26What is the output of the following?
print("Hello {1} and {0}".format('bin', 'foo'))
✅ Correct Answer: 1
27What is the output of the following?
print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
✅ Correct Answer: 1
28 What is the output of the following?
print('ab'.isalpha())
✅ Correct Answer: 1
29 What is the output of the following?
print('1.1'.isnumeric())
✅ Correct Answer: 2
30What is the output of the following?
print('a'.maketrans('ABC', '123'))
✅ Correct Answer: 1
31What is the output of the following?
print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
✅ Correct Answer: 2
32. What is the output of the following?
print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
✅ Correct Answer: 1
33 What is the output of the following piece of code when executed in the python shell?
a={1,2,3}
a.intersection_update({2,3,4,5})
a
✅ Correct Answer: 2
34Which of the following lines of code will result in an error?
✅ Correct Answer: 4
35 What is the output of the code shown below?
s=set([1, 2, 3])
s.union([4, 5])
s|([4, 5])
✅ Correct Answer: 3
36What is the output of the line of code shown below, if s1= {1, 2, 3}?
s1.issubset(s1)
✅ Correct Answer: 1
37What will be the output?
d = {"john":40, "peter":45}
d["john"]
✅ Correct Answer: 1
38 What is the output of the following piece of code when executed in Python shell?
a=("Check")*3
a
✅ Correct Answer: 3
39 Is the following piece of code valid?
a=2,3,4,5
a
✅ Correct Answer: 4
40 What is the output of the following code?
a,b=6,7
a,b=b,a
a,b
✅ Correct Answer: 3
41How many keyword arguments can be passed to a function in a single function call?
✅ Correct Answer: 3
42 What is the output of the code shown below?
def f1():
x=100
print(x)
x=+1
f1()
A.
✅ Correct Answer: 2
43On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false.
✅ Correct Answer: 2
44. Which of these is false about recursion?
✅ Correct Answer: 3
45What is the output of the code shown below?
l1=[1, 2, 3, [4]]
l2=list(l1)
id(l1)==id(l2)
✅ Correct Answer: 2
46What are the methods which begin and end with two underscore characters called?
✅ Correct Answer: 1
47What is the output of the code shown below?
def f(x):
yield x+1
print("test")
yield x+2
g=f(9)
✅ Correct Answer: 4
48The output of the code shown below is:
int('65.43')
✅ Correct Answer: 2
49What is the output of the following piece of code?
class A():
def disp(self):
print("A disp()")
class B(A):
pass
obj = B()
obj.disp()
✅ Correct Answer: 4
50What is the output of the following piece of code?
class Demo:
def __init__(self):
self.x = 1
def change(self):
self.x = 10
class Demo_derived(Demo):
def change(self):
self.x=self.x+1
return self.x
def main():
obj = Demo_derived()
print(obj.change())
main()
✅ Correct Answer: 4
51 What is the result of the expression if x=15 and y=12:
✅ Correct Answer: 3
52What is the value of this expression:
bin(10-2)+bin(12^4)
✅ Correct Answer: 4
53What is the two's complement of -44?
✅ Correct Answer: 2
54What is the output of the code shown below?
not(3>4)
not(1&1)
✅ Correct Answer: 2
55What is the output of the code shown below?
class Truth:
pass
x=Truth()
bool(x)
✅ Correct Answer: 2
56What is the value of x if:
x = int(43.55+2/2)
✅ Correct Answer: 2
57What is the value of the expression:
4+2**5//10
✅ Correct Answer: 2
58What is the value of the following expression:
24//6%3, 24//4//2
✅ Correct Answer: 1
59What is the output of the following?
i = 2
while True:
if i%3 == 0:
break
print(i)
i += 2
✅ Correct Answer: 2
60What is the output of the following?
x = "abcdef"
i = "i"
while i in x:
print(i, end=" ")
✅ Correct Answer: 1
61What is the output of the following?
x = 'abcd'
for i in x:
print(i.upper())
✅ Correct Answer: 2
62What is the output of the following?
x = 'abcd'
for i in range(len(x)):
x[i].upper()
print (x)
✅ Correct Answer: 1
63 What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
print(x)
✅ Correct Answer: 2
64. What is the output of the following?
for i in range(float('inf')):
print (i)
✅ Correct Answer: 4
65What is the output of the following?
string = "my name is x"
for i in string.split():
print (i, end=", ")
✅ Correct Answer: 3
66What is the output of the following?
a = [0, 1, 2, 3]
for a[0] in a:
print(a[0])