Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

15. (04.03 lc) list indexing begins at 1. consider the code segment bel…

Question

  1. (04.03 lc)

list indexing begins at 1. consider the code segment below.
coffee ← \drip\, \espresso\, \caffe latte\, \cappuccino\
which of the following is a valid index for the list? (5 points)
○ 2.5
○ -1
○ 3
○ \drip\

Explanation:

Step1: Count list elements

The list coffee has 4 elements, so valid 1-based indices are $1, 2, 3, 4$.

Step2: Evaluate each option

  • 2.5: Non-integer, invalid.
  • -1: Negative, invalid for 1-based indexing.
  • 3: Integer within $1$ to $4$, valid.
  • "Drip": Is a list value, not an index, invalid.

Answer:

C. 3