1. What is the output of the following?
x = 2
for i in range(x):
x -= 2
print (x)
2. What is the output of the following?
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
Correct Answer is : 0 1 2 3 4
3. What is the output of the following?
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
Correct Answer is : 0 1 2 3 4 Here
4. What is the output of the following?
x = (i for i in range(3))
for i in x:
print(i)
Correct Answer is : 36527
5. What is the output of the following?
x = (i for i in range(3))
for i in x:
print(i)
for i in x:
print(i)
Correct Answer is : 36527
6. What is the output of the following?
string = "my name is x"
for i in string:
print (i, end=", ")
Correct Answer is : m, y, , n, a, m, e, , i, s, , x,
7. What is the output of the following?
string = "my name is x"
for i in string.split():
print (i, end=", ")
Correct Answer is : my, name, is, x,
8. What is the output of the following?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
Correct Answer is : 0 1 2 2
9. What is the output of the following?
a = [0, 1, 2, 3]
for a[0] in a:
print(a[0])
Correct Answer is : 0 1 2 3
10. What is the output of the following?
a = [0, 1, 2, 3]
i = -2
for i not in a:
print(i)
i += 1
Correct Answer is : error
11. What is the output of the following?
string = "my name is x"
for i in ' '.join(string.split()):
print (i, end=", ")
Correct Answer is : m, y, , n, a, m, e, , i, s, , x,