CBSE Class 11 Computer Science Question 105 of 114

Tuples — Question 8

Back to all questions
8
Question

Question 7

Write a program that inputs two tuples and creates a third, that contains all elements of the first followed by all elements of the second.

Solution
tup1 = eval(input("Enter the elements of first tuple: "))
tup2 = eval(input("Enter the elements of second tuple: "))
tup3 = tup1 + tup2
print(tup3)
Output
Enter the elements of first tuple: 1,3,5,7,9  
Enter the elements of second tuple: 2,4,6,8,10
(1, 3, 5, 7, 9, 2, 4, 6, 8, 10)
Answer