0
0
Pythonprogramming~5 mins

List concatenation and repetition in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the + operator do when used with two lists in Python?
The + operator joins two lists end-to-end, creating a new list with elements from both lists in order.
Click to reveal answer
beginner
What is the result of [1, 2] * 3 in Python?
It repeats the list [1, 2] three times, resulting in [1, 2, 1, 2, 1, 2].
Click to reveal answer
intermediate
Can you use + and * operators together on lists? What happens?
Yes. You can concatenate lists with + and then repeat the result with *. For example, ([1] + [2]) * 2 gives [1, 2, 1, 2].
Click to reveal answer
beginner
Does list concatenation with + modify the original lists?
No. The + operator creates a new list and does not change the original lists.
Click to reveal answer
beginner
What happens if you multiply a list by zero, like [1, 2, 3] * 0?
You get an empty list [] because repeating zero times means no elements.
Click to reveal answer
What is the output of [1, 2] + [3, 4]?
A[4, 3, 2, 1]
B[1, 2, 3, 4]
C[1, 2]
D[3, 4]
What does [0] * 5 produce?
A[0]
B[5]
C[0, 0, 0, 0, 0]
DError
Which operator is used to repeat a list multiple times?
A*
B/
C-
D+
What is the result of [1, 2] + [3] * 2?
A[1, 2, 3, 3]
B[1, 2, 3, 2]
C[1, 2, 3]
D[3, 3]
Does list1 + list2 change list1?
ANo, it deletes list1
BYes, it modifies list1
CYes, it modifies list2
DNo, it creates a new list
Explain how list concatenation and repetition work in Python with examples.
Think about how you can join two groups of items or repeat a group multiple times.
You got /4 concepts.
    What happens if you multiply a list by zero or a negative number? Why?
    Consider how repeating something zero times means you get nothing.
    You got /3 concepts.