0
0
Pythonprogramming~5 mins

Tuple creation in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A[7]
B(7)
C(7,)
D{7}
What will be the type of the variable x = 1, 2, 3?
Astring
Blist
Cint
Dtuple
How do you create an empty tuple?
A()
B[]
C{}
DNone
Which statement about tuples is true?
ATuples can be changed after creation
BTuples are immutable
CTuples are unordered
DTuples can only hold numbers
What will type((5)) return?
Aint
Btuple
Clist
Dstr
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.