Strengthen your understanding of Python tuples with beginner-friendly exercises. Practice tuple creation, indexing, unpacking, and immutability through hands-on coding questions.
Topic: tuples
Create a tuple containing three colors and print the second element.
green
Given a tuple (1, 2, 3, 4, 5), create a new tuple with elements from index 1 to 3.
(2, 3, 4)
Count how many times the number 2 appears in the tuple (1, 2, 3, 2, 4, 2).
3
Combine two tuples (1, 2, 3) and (4, 5, 6) into a single tuple.
(1, 2, 3, 4, 5, 6)
Find the index of the first occurrence of "apple" in the tuple ("banana", "apple", "orange", "apple").
1
Convert the list [1, 2, 3] to a tuple and print it.
(1, 2, 3)
Create a new tuple by repeating the tuple (1, 2) three times.
(1, 2, 1, 2, 1, 2)
Unpack the tuple (10, 20, 30) into three variables a, b, c and print them.
10 20 30
Reverse the tuple (1, 2, 3, 4, 5) using slicing.
(5, 4, 3, 2, 1)
Access the value "python" from the nested tuple (("java", "python"), ("c++", "ruby")).
python