← Quiz: Reliability Patterns: all 10 questions
Quiz: Reliability Patterns · Question 7 of 10
What does this print? (code)
What does this print?
state, failures = "CLOSED", 0
for ok in [False, True, False, False, False]:
if ok:
failures = 0
else:
failures += 1
if failures >= 3:
state = "OPEN"
print(state, failures)
- A.CLOSED 3
- B.OPEN 3
- C.OPEN 4
- D.CLOSED 4
Answer & explanation
Correct answer: OPEN 3
The success resets the count, then three more failures in a row trip the breaker.
Can you get the rest right without peeking?
Take the timed Quiz: Reliability Patterns quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →