CBSE Class 11 Informatics Practices Question 36 of 80

Lists in Python — Question 14

Back to all questions
14
Question

Question 14

Find the output of the following code:

number = [1, 5, 7, 0, 4]
print(number[2:3])
  1. [5]
  2. [7]
  3. [7,0]
  4. None of these
Answer

[7]

Reason — The slice number[2:3] extracts a subset of the list starting from index 2 (inclusive) up to, but not including, index 3. In this case, index 2 corresponds to the element 7 in the list number. Therefore, number[2:3] results in [7].