Embercode
✕
ConditionalsQuick quiz

Ranges

6 questions. Covers Range checks in Python.

Questions 1 to 5 of 6

  1. 1. This check should accept only whole numbers from 1 to 10. What is the bug? ``python x = 50 if x >= 1 or x <= 10: print("in range") ``
  2. 2. Why does this loop crash? ``python items = [10, 20, 30] for i in range(len(items) + 1): if 0 <= i <= len(items): print(items[i]) ``
  3. 3. What does this program print? ``python a = 1 b = 10 print(1 <= a < 10, 1 <= b < 10) ``
  4. 4. What does this program print? ``python import math nan = math.nan print(0.0 <= nan <= 1.0, not (0.0 <= nan <= 1.0)) ``
  5. 5. The function in_range(x, low, high) returns x >= low and x <= high. Does in_range(5, 10, 1) return True?

5 question(s) left on this page.