MCQ Practice Single Best Answer Topic: Python Generators MCQ

Q What will be the output after the following statements?
 def gen():
    x = 2
    while True:
        yield x
        x += 1
y = gen()
for i in y:
    if i >= 5:
        break
    else:
        print(i, end='')

Question ID
#3554
Subchapter
Python Generators MCQ
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 0123
  • B 123
  • C 12345
  • D 234
Correct Answer: D

Explanation

234

Share This Question

Share this MCQ with your friends or study group.