TRUE
FALSE
What will be the output of the following Python code snippet?
>>bool(‘False’) >>bool()
True True
False True
False False
True False
not(3>4) not(1&1)
not(-6<0 or-6>10)
-6>=0 and -6<=10
not(-6<10 or-6==10)
not(-6>10 or-6==10)
not(10<20) and not(10>30)
True
False
Error
No output
What will be the output of the following Python code?
print('{a}{b}{a}'.format(a='hello', b='world'))
‘hello world’
‘hello’ ‘world’ ‘hello’
‘helloworldhello’
‘hello’ ‘hello’ ‘world’
x = ['ab', 'cd'] for i in x: i.upper() print(x)
[‘ab’, ‘cd’]
[‘AB’, ‘CD’]
[None, None]
none of the mentioned
x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
[‘ab’, ‘cd’, ‘AB’, ‘CD’]
Infinite Loop
i = 1 while True: if i%3 == 0: break print(i) i + = 1
1 2
1 2 3
error
i = 1 while True: if i%7 == 0: break print(i) i += 1
1 2 3 4 5 6
1 2 3 4 5 6 7
i = 1 while True: if i%2 == 0: break print(i) i += 2
1
1 2 3 4 5 6 …
1 3 5 7 9 11 … infinite time
i = 2 while True: if i%3 == 0: break print(i) i += 2
2 4 6 8 10 …
2 4
2 3
i = 1 while False: if i%2 == 0: break print(i) i += 2
1 3 5 7 …
1 2 3 4 …
Nothing will be printed
i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)
0 1 2 0
0 0 1 0 2
i = 0 while i < 3: print(i) i += 1 else: print(0)
0 1 2 3 0
0 1 2
x = "abcdef" while i in x: print(i, end=" ")
a b c d e f
abcdef
i i i i i i …
x = "abcdef" i = "i" while i in x: print(i, end=" ")
no output
x = "abcdef" i = "a" while i in x: print(i, end = " ")
a a a a a a …
x = "abcdef" i = "a" while i in x: print('i', end = " ")
i i i i i i … infinite Time
x = "abcdef" i = "a" while i in x: x = x[:-1] print(i, end = " ")
i i i i i i
a a a a a a
a a a a a