🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.CLOSED 3
  2. B.OPEN 3
  3. C.OPEN 4
  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 →