Recall & Review
beginner
What is a tuple in Python?
A tuple is a collection of items which is ordered and unchangeable (immutable). It can hold multiple items of different types.
Click to reveal answer
beginner
How do you create an empty tuple?
You create an empty tuple by using empty parentheses:
().Click to reveal answer
beginner
How do you create a tuple with one item?
You create a single-item tuple by adding a comma after the item inside parentheses, like
(5,). Without the comma, it is not a tuple.Click to reveal answer
intermediate
What is the difference between
(1, 2, 3) and 1, 2, 3 in Python?Both represent tuples. Parentheses are optional when creating tuples, so
1, 2, 3 is also a tuple of three items.Click to reveal answer
beginner
Can you change the items inside a tuple after it is created?
No, tuples are immutable. Once created, you cannot change, add, or remove items inside a tuple.
Click to reveal answer
Which of the following is a valid tuple with one element?
✗ Incorrect
A single-item tuple requires a comma after the item inside parentheses, like (7,). (7) is just the number 7 in parentheses.
What will be the type of the variable
x = 1, 2, 3?✗ Incorrect
When you separate values by commas without brackets, Python creates a tuple by default.
How do you create an empty tuple?
✗ Incorrect
Empty parentheses create an empty tuple. [] is an empty list, {} is an empty dictionary.
Which statement about tuples is true?
✗ Incorrect
Tuples cannot be changed after creation, they are ordered and can hold any data type.
What will
type((5)) return?✗ Incorrect
Parentheses around a single value without a comma do not create a tuple, so (5) is just the integer 5.
Explain how to create tuples in Python and how to create a single-item tuple.
Remember the comma is key for single-item tuples.
You got /3 concepts.
Describe the immutability of tuples and what it means for modifying tuple contents.
Think about whether you can add or remove items after creation.
You got /3 concepts.