CBSE Class 11 Computer Science Question 34 of 114

Tuples — Question 11

Back to all questions
11
Question

Question 11

What will be the output of the following Python code?

tp = (5,)  
tp1 = tp * 2   
print(len(tp1))  
  1. 0
  2. 2
  3. 1
  4. Error
Answer

2

Reason — The "*" operator performs repetition in tuples. tp1 = tp * 2 will result in tp1 as (5, 5) so its length will be 2.