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.

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

tuple()
//()

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.

Examples:

tuple((1, 2, 3))#tuple to tuple, returns a replica tuple
//(1, 2, 3)
tuple(['Python', 'Java', 'C++', 'Ruby'])#list to tuple
//('Python', 'Java', 'C++', 'Ruby')
tuple({'Nairobi', 'Denver', 'Tokyo', 'Helsinki'})#set to tuple
//('Nairobi', 'Denver', 'Helsinki', 'Tokyo')
tuple("Hello, World!")#string to tuple
//('H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!')
tuple(range(5))#range to tuple
//(0, 1, 2, 3, 4)
tuple({'Kenya':'Nairobi', 'USA':'Washington', 'Japan':'Tokyo', 'Finland':'Helsinki'})#dictionary to tuple, only keys are considered.
//('Kenya', 'USA', 'Japan', 'Finland')