Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
<<
**
|
%
What will be the value of the following Python expression?
print(float(4+int(2.39)%2))
5.0
5
4.0
4
4.0 + float(3)
5.3 + 6.3
5.0 + 3
3 + 7
float(‘10’)
int(‘10’)
float(’10.8’)
int(’10.8’)
print(4+2**5//10)
3
7
77
0
What will be the output of the following Python code snippet?
>>bool(‘False’) >>bool()
True True
False True
False False
True False
print(not(3>4)) print(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)
What will be the output of the following Python code?
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%7 == 0: break print(i) i += 1
1 2 3 4 5 6
1 2 3 4 5 6 7
error
i = 1 while True: if i%2 == 0: break print(i) i += 2
1
1 2
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 < 3: print(i) i += 1 else: print(0)
0 1 2 3 0
0 1 2 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