31
What will be the output of the following Python code snippet?
a = [0, 1, 2, 3]
for a[0] in a:
print(a[0])
Answer & Solution
Answer: Option
A
32
What will be the output of the following Python code?
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
Answer & Solution
Answer: Option
A
33
What will be the output of the following Python code?
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
Answer & Solution
Answer: Option
C
34
What will be the output of the following Python code snippet?
string = "my name is x"
for i in ' '.join(string.split()):
print (i, end=", ")
Answer & Solution
Answer: Option
A
35
What will be the output of the following Python code?
x = (i for i in range(3))
for i in x:
print(i)
for i in x:
print(i)
Answer & Solution
Answer: Option
A
36
What will be the output of the following Python code?
string = "my name is x"
for i in string:
print (i, end=", ")
Answer & Solution
Answer: Option
A
37
What will be the output of the following Python code snippet?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
Answer & Solution
Answer: Option
B
38
What will be the output of the following Python code?
x = (i for i in range(3))
for i in x:
print(i)
Answer & Solution
Answer: Option
A
39
What will be the output of the following Python code?
string = "my name is x"
for i in string.split():
print (i, end=", ")
Answer & Solution
Answer: Option
C
40
What will be the output of the following Python code snippet?
a = [0, 1, 2, 3]
i = -2
for i not in a:
print(i)
i += 1
Answer & Solution
Answer: Option
C