CBSE Class 11 Computer Science Question 2 of 18

Practice Paper — Question 11

Back to all questions
11
Question

Question 11

Observe the given code and select the appropriate output.

Tuple given: tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)

What will be the output of: print(tup1[3:7:2])

  1. (40, 50, 60, 70, 80)
  2. (40, 50, 60, 70)
  3. (40, 60)
  4. Error
Answer

(40, 60)

Reason — The slice tup1[3:7:2] extracts elements starting from index 3 up to index 6, with a step of 2. This means it selects elements at indices 3, 5, resulting in the tuple (40, 60). The print statement outputs these selected elements.

Get the Bright Tutorials app Stuck on a question? Ask Bright Buddy — your AI tutor — for step-by-step help in the app.