Mathematics I / Arrays and Lists
Practice question · Select all that apply

Let a be the list 3, 1, 4, 1, 5 with zero-based indexing. Select every TRUE statement.

Hints
  1. Write the indices 0..4 above the values before judging anything.
  2. One option uses an index that does not exist at all.
Show the answer
  • A. the length of a is 5
  • C. a[0] is 3
  • E. a[4] is 5
Why

a[0] = 3, a[2] = 4 (not 1), the length is 5, a[4] = 5, and a[5] is out of bounds rather than 5. the second option is tempting precisely because the value 5 does appear in the list, but not at that index.

Read the lesson: Arrays and Lists →

Practise Arrays and Lists

The app has 5 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Arrays and Lists