What will be the output of the following Python code?
x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
[‘AB’, ‘CD’]
[‘ab’, ‘cd’, ‘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
none of the mentioned
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
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
a a a a a a … infinite Time
a
x = "abcdef" i = "a" while i in x: x = x[1:] print(i, end = " ")
x = 'abcd' for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
x = 'abcd' for i in range(x): print(i)
0 1 2 3
x = 'abcd' for i in range(len(x)): print(i)
1 2 3 4
x = 'abcd' for i in range(len(x)): print(i.upper())
What will be the output of the following Python code snippet?
x = 'abcd' for i in range(len(x)): i.upper() print (x)