← 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)
- A.ok
- B.2
- C.blocked
- 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 →