🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Test Case Design: all 10 questions

Quiz: Test Case Design · Question 9 of 10

What does this print? (code)

What does this print?

state = 0
for pin in ['1', '2', '9', '9']:
    if state == 'blocked':
        break
    if pin == '9':
        state = 'ok'
        break
    state += 1
    if state == 2:
        state = 'blocked'
print(state)
  1. A.ok
  2. B.2
  3. C.blocked
  4. D.0
Answer & explanation

Correct answer: blocked

Two wrong PINs make state 2, which becomes 'blocked', and the loop stops before the correct PIN.

Can you get the rest right without peeking?

Take the timed Quiz: Test Case Design quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →