Bird
Raised Fist0

What will be the output of the following Python code?

medium📝 Analysis Q13 of Q15
Intro to Computing - How Files and Folders Organize Data
What will be the output of the following Python code?
items = [3, 7, 1, 9, 7]
print(items.index(7))
AError
B3
C4
D1
Step-by-Step Solution
Solution:
  1. Step 1: Understand list and index method

    The list items contains [3, 7, 1, 9, 7]. The index() method returns the first position of the value.
  2. Step 2: Find first occurrence of 7

    7 appears first at position 1 (0-based index).
  3. Final Answer:

    1 -> Option D
  4. Quick Check:

    First 7 at index 1 [OK]
Quick Trick: index() returns first match position [OK]
Common Mistakes:
MISTAKES
  • Choosing last occurrence index instead of first
  • Confusing value with index
  • Expecting error due to duplicate values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Intro to Computing Quizzes