Embercode
✕
ConditionalsQuick quiz

Else pairing and nulls

8 questions. Covers None checks before conditions in Python.

Questions 1 to 5 of 8

  1. 1. This shop code is meant to print else part for shop closed when is_open is False. What does it print? ``python hour = 20 is_open = False if is_open: if hour >= 9: print("inside") else: print("else part for shop closed") ``
  2. 2. A function runs len(name) in a condition and crashes with TypeError when name is None. Which condition fixes the crash and keeps the same meaning?
  3. 3. With count = None, which condition is True only when count holds a value greater than zero, and never crashes?
  4. 4. What does this code print? ``python n = 5 if n > 10: if n > 3: print("A") else: print("B") print("C") ``
  5. 5. What does this code print? ``python a = 0 b = 9 if a > 1: if b > 5: print("x") else: print("y") else: print("z") ``

5 question(s) left on this page.