Programming · Flashcard

Which numbers does range(5) produce?

  • A0, 1, 2, 3, 4 — the sequence starts at zero and excludes the stop value
  • B1, 2, 3, 4, 5 — the sequence starts at one and includes the stop value
  • C0, 1, 2, 3, 4, 5 — the sequence covers every number up to and including 5
  • D5, 4, 3, 2, 1 — the sequence counts down from the argument toward one

Why this is the answer

range(stop) yields 0 up to stop-1. It doesn't start at 1, never includes the stop value, and counts upward — descending ranges need an explicit negative step like range(5, 0, -1).

Official docs
Study in Gnoseed →