CBSE Class 11 Computer Science Question 76 of 114

Tuples — Question 13

Back to all questions
13
Question

Question 1(m)

Find the output generated by following code fragments :

t3 = (6, 7)  
t4 = t3 * 3  
t5 = t3 * (3)  
print(t4)  
print(t5)
Answer
Output
(6, 7, 6, 7, 6, 7)  
(6, 7, 6, 7, 6, 7)  
Explanation

The repetition operator * replicates the tuple specified number of times. The statements t3 * 3 and t3 * (3) are equivalent as (3) is an integer not a tuple because of lack of comma inside parenthesis. Both the statements repeat t3 three times to form tuples t4 and t5.