Answers for "Construct a tuple"

0

Construct a tuple

# Different types of tuples

# Empty tuple
my_tuple = ()
print(my_tuple)

# Tuple having integers
my_tuple = (1, 2, 3)
print(my_tuple)

# tuple with mixed datatypes
my_tuple = (1, "Hello", 3.4)
print(my_tuple)

# nested tuple
my_tuple = ("mouse", [8, 4, 6], (1, 2, 3))
print(my_tuple)

>()
>(1, 2, 3)
>(1, 'Hello', 3.4)
>('mouse', [8, 4, 6], (1, 2, 3))
Posted by: Guest on July-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language