Tuples and Dictionaries · Class 11 · CBSE · Science Computer Science

What is printed by the following Python code? t = (4, 7, 9, 7); print(t.index(7), t.count(7))

Practice question from Tuples and Dictionaries (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-C01B21

What is printed by the following Python code? t = (4, 7, 9, 7); print(t.index(7), t.count(7))

  1. A.0 2
  2. B.1 2Correct answer
  3. C.1 1
  4. D.2 1

Solution

The index() method returns the position of the first occurrence of 7, which is 1. The count() method returns the total number of occurrences, which is 2.

More from Tuples and Dictionaries

All of Tuples and Dictionaries

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed