What will be the output of the following Python code?
for i in range(int(2.0)): print(i)
0.0 1.0
0 1
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)
1 2 3 4
4 3 2 1
for i in ''.join(reversed(list('abcd'))): print (i)
a b c d
d c b a
for i in 'abcd'[::-1]: print (i)
x = 2 for i in range(x): x += 1 print (x)
0 1 2 3 4 …
3 4
0
x = 2 for i in range(x): x -= 2 print (x)
0 -2
for i in range(10): if i == 5: break else: print(i) else: print("Here")
0 1 2 3 4 Here
0 1 2 3 4 5 Here
0 1 2 3 4
1 2 3 4 5
for i in range(5): if i == 5: break else: print(i) else: print("Here")
x = (i for i in range(3)) for i in x: print(i)
0 1 2
0 1 2 0 1 2
string = "my name is x" for i in string: print (i, end=", ")
m, y, , n, a, m, e, , i, s, , x,
m, y, , n, a, m, e, , i, s, , x
my, name, is, x,
string = "my name is x" for i in string.split(): print (i, end=", ")
a = [0, 1, 2, 3] for a[-1] in a: print(a[-1])
0 1 2 3
0 1 2 2
3 3 3 3
a = [0, 1, 2, 3] for a[0] in a: print(a[0])
What will be the output of the following Python statement?
>>>"a"+"bc"
a
bc
bca
abc
>>>"abcd"[2:]
ab
cd
dc
+
*
–
All of the mentioned
>>>print('new' 'line')
Error
Output equivalent to print ‘newline’
newline
new line
>>>str1="helloworld"
>>>str1[::-1]
dlrowolleh
hello
world
helloworld
0xA0xB0xC
0x22
33
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
snow
snow world
snos world