0
0
Pythonprogramming~10 mins

List concatenation and repetition in Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to concatenate two lists.

Python
result = [1, 2, 3] [1] [4, 5, 6]
Drag options to blanks, or click blank then click option'
A+
B*
C/
D-
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '*' instead of '+' causes an error or unexpected behavior.
Using '-' or '/' are not valid for lists.
2fill in blank
medium

Complete the code to repeat the list three times.

Python
result = [0, 1] [1] 3
Drag options to blanks, or click blank then click option'
A-
B+
C/
D*
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' concatenates lists but does not repeat.
Using '-' or '/' are not valid for lists.
3fill in blank
hard

Fix the error in the code to correctly concatenate two lists.

Python
result = [1, 2, 3] [1] [4]
Drag options to blanks, or click blank then click option'
A-
B*
C+
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Trying to add a list and an integer directly causes an error.
Using '*' with a number on the right repeats the list, but here the right side is not a list.
4fill in blank
hard

Fill both blanks to create a list of three repetitions of [7, 8] concatenated with [9].

Python
result = [7, 8] [1] 3 [2] [9]
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' before '*' changes the order of operations.
Using '-' or '/' causes errors.
5fill in blank
hard

Fill all three blanks to create a list with the uppercase letters repeated twice and concatenated with ['Z'].

Python
letters = ['a', 'b', 'c']
result = [[1] for l in letters] [2] 2 [3] ['Z']
Drag options to blanks, or click blank then click option'
Al.upper()
B*
C+
Dl.lower()
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using l.lower() instead of l.upper().
Using '+' instead of '*' for repetition.
Using '*' instead of '+' for concatenation.