Computer Science
Can you have an integer, a string, a tuple of integers and a tuple of strings in a tuple?
Python Tuples
1 Like
Answer
Yes, it is possible to have an integer, a string, a tuple of integers and a tuple of strings in a tuple because tuples can store elements of all data types.
For example:
tup = (1, 'python', (2, 3), ('a', 'b'))
Answered By
1 Like
Related Questions
What does a + b amount to if a is a tuple and b is 5?
Is a string the same as a tuple of characters?
Which of the following statements will create a tuple:
- tp1=("a", "b")
- tp1[2]=("a", "b")
- tp1=(3)*3
- None of these
Choose the correct statement(s).
- Both tuples and lists are immutable.
- Tuples are immutable while lists are mutable.
- Both tuples and lists are mutable.
- Tuples are mutable while lists are immutable.