w3resource

Python Exercise: Create a tuple


Write a Python program to create a tuple.

Sample Solution:

Python Code:

# Create an empty tuple and assign it to the variable 'x'
x = ()
# Print the contents of the 'x' tuple, which is empty
print(x)

# Create an empty tuple using the tuple() constructor and assign it to the variable 'tuplex'
tuplex = tuple()
# Print the contents of the 'tuplex' tuple, which is also empty
print(tuplex) 

Sample Output:

()                                                                                                            
()

Flowchart:

Flowchart: Create a tuple

Python Code Editor:

Previous: Python Tuple Exercise Home
Next: Write a Python program to create a tuple with different data types.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.