🎙 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 6 of 13

What does this print? (code)

What does this print?

n = 3
while n:
    print(n, end=" ")
    n -= 1
  1. A.3 2 1
  2. B.3 2 1 0
  3. C.2 1 0
  4. D.It runs forever
Answer & explanation

Correct answer: 3 2 1

The loop stops when n becomes 0 (falsy).

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 →