Font size
WorksheetsPython Parithabangal
Total questions: 25
Worksheet time: 17mins
What will be the value of the following Python expression?
print(4 + 3 % 5)
4
7
2
0
What will be the value of x in the following Python expression?
x = int(43.55+2/2)
print(x)
43
44
23
22
What are the values of the following Python expressions?
print(2**(3**2))
print((2**3)**2)
print(2**3**2)
64, 512, 64
64, 64, 64
512, 512, 512
512, 64, 512
What will be the output of the following Python code snippet if x=1?
x<<2
8
1
2
4
What will be the output of the following Python expression if x=15 and y=12?
x & y
b1101
0b1101
12
1101
What will be the output of the following Python code?
True = False
while True:
print(True)
break
True
False
ERROR
none of the mentioned
What will be the output of the following Python code?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
0 1 2 3 0
0 1 2 0
0 1 2
error
What will be the output of the following Python code?
x = 123
for i in x:
print(i)
1 2 3
123
error
none of the mentioned
What will be the output of the following Python code snippet?
for i in [1, 2, 3, 4][::-1]:
print(i, end=' ')
1 2 3 4
4 3 2 1
error
none of the mentioned
What will be the output of the following Python code snippet?
x = 2
for i in range(x):
x += 1
print (x)
0 1 2 3
0 1
3 4
error
What will be the output of the following Python code?
print(0xA + 0xB + 0xC)
0xA0xB0xC
Error
0x22
33
To concatenate two strings to a third what statements are applicable?
s3 = s1 . s2
s3 = s1.add(s2)
s3 = s1.__add__(s2)
s3 = s1 * s2
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
[2, 33, 222, 14]
Error
25
[25, 14, 222, 33, 2]
Suppose list1 is [1, 3, 2], What is list1 * 2?
[2, 6, 4]
[1, 3, 2, 1, 3]
[1, 3, 2, 1, 3, 2]
[1, 3, 2, 3, 2, 1]
What will be the output of the following Python code?
my_tuple = (1, 2, 3, 4)
my_tuple.append( (5, 6, 7) )
print len(my_tuple)
1
2
5
Error
What type of data is: a=[(1,1),(2,4),(3,9)]?
Array of tuples
List of tuples
Tuples of lists
Invalid type
If a={5,6,7}, what happens when a.add(5) is executed?
a={5,5,6,7}
a={5,6,7}
Error as there is no add function for set data type
Error as 5 already exists in the set
What will be the output of the following Python code snippet?
for x in set('pqr'):
print(x*2)
pp qq rr
pqr pqr
ppqqrr
pqrpqr
What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
print(d1 == d2)
True
False
None
Error
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
1
A
4
Invalid syntax for get method
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"}
a.clear()
print(a)
None
{ None:None, None:None, None:None}
{1:None, 2:None, 3:None}
{ }
What will be the output of the following Python code?
def say(message, times = 1):
print(message * times)
say('Hello')
say('World', 5)
Hello WorldWorldWorldWorldWorld
Hello World 5
Hello World,World,World,World,World
Hello HelloHelloHelloHelloHello
Which are the advantages of functions in python?
Reducing duplication of code
Decomposing complex problems into simpler pieces
Improving clarity of the code
All of the mentioned
What will be the output of the following Python code?
def test(i,j):
if(i==0):
return j
else:
return test(i-1,i+j)
print(test(4,7))
13
7
Infinite loop
17
Draw your best friend and mention their name

