Computer Science

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

Python Tuples

2 Likes

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.

Answered By

2 Likes


Related Questions