Computer Science
What will be the output of following Python code?
tp1 = (2,4,3)
tp3 = tp1*2
print(tp3)
- (4,8,6)
- (2,4,3,2,4,3)
- (2,2,4,4,3,3)
- Error
Python Tuples
4 Likes
Answer
(2,4,3,2,4,3)
Reason — The "*" operator repeats a tuple specified number of times and creates a new tuple.
Answered By
2 Likes
Related Questions
Which of the following is/are correctly declared tuple(s) ?
- a = ("Hina", "Mina", "Tina", "Nina")
- a = "Hina", "Mina", "Tina", "Nina")
- a = ["Hina", "Mina", "Tina", "Nina"]
- a = (["Hina", "Mina", "Tina", "Nina"])
Which of the following will create a single element tuple ?
- (1,)
- (1)
- ( [1] )
- tuple([1])
What will be the output of following Python code?
tp1 = (15,11,17,16,12) tp1.pop(12) print(tp1)
- (15,11,16,12)
- (15,11,17,16)
- (15,11,17,16,12)
- Error
Which of the following options will not result in an error when performed on types in Python where tp = (5,2,7,0,3) ?
- tp[1] = 2
- tp.append(2)
- tp1=tp+tp
- tp.sum()