Write a Python program to create a Tuple with an example. In Python Programming language, there are two ways to create a Tuple. The first option is using the () brackets, and the other option is the tuple() function.
The following Python example creates an empty tuple using both the options.
x = () print(x) y = tuple() print(y)
Output of an Empty Tuple
()
()
In this example program, we are creating a tuple of items. We all know that the tuple function accepts any iterator and converts it into the tuple. So, we declared a fruits list and used the Python tuple function to convert it into a tuple.
x = (10, 20, 30, 40, 50) print(x) print("Datatype of y = ", type(x)) fruits = ['Kiwi', 'Banana', 'Apple', 'Orange'] y = tuple(fruits) print(y) print("Datatype of Fruits = ", type(fruits)) print("Datatype of y = ", type(y))