Embercode
✕
LoopsQuick quiz

Steps and half-open ranges

8 questions. Covers Half-open ranges in Python.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``python for i in range(5, 31, 7): print(i, end=" ") print() print("i =", i) ``
  2. 2. What does this program print? ``python a = [2, 4, 6, 8, 10, 12] total = 0 for i in range(1, 4): total += a[i] print(total) ``
  3. 3. What does this program print? ``python word = "forgestack" print(word[5:9]) print(len(range(3, 9))) ``
  4. 4. This loop is meant to print every item of scores, which has 3 items. What is the bug? ``python scores = [72, 85, 90] for i in range(0, len(scores) + 1): print(scores[i]) ``
  5. 5. Which pair of range objects covers positions 0 to 8 of a list exactly once?

5 question(s) left on this page.