QUESTION IMAGE
Question
- (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\
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.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
C. 3