CBSE Class 11 Computer Science Question 42 of 88

Tuples and Dictionary — Question 7

Back to all questions
7
Question

Question 7

What is nested tuple? Explain with example.

Answer

A nested tuple is a tuple that contains other tuples as its elements. When we add one or more tuples inside another tuple, the items in the nested tuples are combined together to form a new tuple.

For example,

tuple1 = (0, 1, 2, 3)
tuple2 = ('python', 'book')
tuple3 = (tuple1, tuple2)
print(tuple3)
Output
((0, 1, 2, 3), ('python', 'book'))