The tuple() function is used to create a tuple from a given iterable object. It is also used without any argument to create an empty tuple:

Syntax:
tuple() #create empty tuple
tuple(iterable)#create a tuple from an iterable.
copy

When the function is called without any argument, it simply returns an empty tuple.

ExampleEdit & Run
T = tuple()

print( T )
copy
Output:
() [Finished in 0.010525227524340153s]

When the function is called with an iterable object such as a list, set, range, etc, it creates a new tuple object containing the elements from the iterable. An operation like this one which involves explicitly turning an object from one type to another is known as type casting. In this case we are casting objects from other types to tuple.

ExampleEdit & Run
T = tuple((1, 2, 3))#tuple to tuple, returns a replica tuple
print( T )

T = tuple(['Python', 'Java', 'C++', 'Ruby'])#list to tuple
print( T )

T = tuple({'Nairobi', 'Denver', 'Tokyo', 'Helsinki'})#set to tuple
print( T )

T = tuple("Hello, World!")#string to tuple
print( T )

T = tuple(range(5))#range to tuple
print( T )

T = tuple({'Kenya':'Nairobi', 'USA':'Washington', 'Japan':'Tokyo', 'Finland':'Helsinki'})#dictionary to tuple, only keys are considered.
print( T )
copy
Output:
(1, 2, 3) ('Python', 'Java', 'C++', 'Ruby') ('Nairobi', 'Helsinki', 'Denver', 'Tokyo') ('H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!') (0, 1, 2, 3, 4) ('Kenya', 'USA', 'Japan', 'Finland') [Finished in 0.01051973644644022s]