Join Two Tuples
The + operator combines two or more tuples into a single tuple:
Example
Combine two tuples with +:
Prompt
Create two tuples: one with letters "a", "b", "c" and one with numbers 1, 2, 3.
Join them using the
+ operator and print the result.
Output: complete Python program
main.py
tuple1 = ("a", "b" , "c")
tuple2 = (1, 2, 3)
tuple3 = tuple1 + tuple2
print(tuple3)
Multiply Tuples
The * operator repeats the content of a tuple as many times as you ask:
Example
Multiply fruits by 2 to get each item twice:
Prompt
Create a tuple with three fruits. Multiply it by 2 using the
* operator and print the result.
Output: complete Python program
main.py
fruits = ("apple", "banana", "cherry")
mytuple = fruits * 2
print(mytuple)