🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python Loops: all 13 questions

Quiz: Python Loops · Question 10 of 13

What does this print? (code)

What does this print?

n = 1
while True:
    n *= 2
    if n > 20:
        break
print(n)
  1. A.16
  2. B.20
  3. C.The loop never ends
  4. D.32
Answer & explanation

Correct answer: 32

n becomes 2, 4, 8, 16, 32; 32 is the first value above 20, so break stops the loop.

Can you get the rest right without peeking?

Take the timed Quiz: Python Loops quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →