nerdexam
Python_Institute

PCEP-30-02 · Question #305

How many stars will the following code print to the monitor? i = 0 while i < i + 2: i += 1 print('') else: print('')

The correct answer is C. The snippet will enter an infinite loop. See the full explanation below for the reasoning.

Question

How many stars will the following code print to the monitor? i = 0 while i < i + 2: i += 1 print('') else: print('')

Options

  • Atwo
  • Bone
  • CThe snippet will enter an infinite loop.
  • Dzero

How the community answered

(52 responses)
  • A
    6% (3)
  • B
    4% (2)
  • C
    79% (41)
  • D
    12% (6)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice