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:
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.
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://w3resource.com/python-exercises/tuple/python-tuple-exercise-1.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics