w3resource

Python Exercise: Create a tuple

Python tuple: Exercise-1 with Solution

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/tuple/python-tuple-exercise-1.php