w3resource

Python Exercise: Create a tuple with different data types

Python tuple: Exercise-2 with Solution

Write a Python program to create a tuple with different data types.

Sample Solution:

Python Code:

# Create a tuple containing elements of different data types
tuplex = ("tuple", False, 3.2, 1)
# Print the contents of the 'tuplex' tuple
print(tuplex)

Sample Output:

('tuple', False, 3.2, 1) 

Flowchart:

Flowchart: Create a tuple with different data types

Python Code Editor:

Previous: Write a Python program to create a tuple.
Next: Write a Python program to create a tuple with numbers and print one item.

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://w3resource.com/python-exercises/tuple/python-tuple-exercise-2.php