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.



Follow us on Facebook and Twitter for latest update.