0
0
Pythonprogramming~20 mins

List creation and representation in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
List Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
2:00remaining
Output of list creation with mixed types
What is the output of this Python code?
Python
my_list = [1, '2', 3.0, True]
print(my_list)
A[1, '2', 3.0, True]
B[1, 2, 3.0, True]
C[1, '2', 3, True]
D[1, '2', 3.0, 1]
Attempts:
2 left
๐Ÿ’ก Hint
Remember that strings and numbers are different types and are shown with quotes or without.
โ“ Predict Output
intermediate
2:00remaining
Length of a nested list
What is the value of len(my_list) after running this code?
Python
my_list = [1, [2, 3], 4]
print(len(my_list))
A4
B3
C5
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
len() counts the top-level items in the list, not inside nested lists.
โ“ Predict Output
advanced
2:00remaining
Output of list multiplication with nested lists
What is the output of this code?
Python
lst = [[0]] * 3
lst[0][0] = 5
print(lst)
A[[5], [5], [5]]
B[[0], [0], [0]]
C[[5], [0], [0]]
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
Multiplying a list with nested lists copies references, not independent copies.
โ“ Predict Output
advanced
2:00remaining
Output of list comprehension with condition
What is the output of this code?
Python
result = [x**2 for x in range(5) if x % 2 == 0]
print(result)
ASyntaxError
B[1, 9, 25]
C[0, 4, 16]
D[0, 1, 4, 9, 16]
Attempts:
2 left
๐Ÿ’ก Hint
The condition filters only even numbers before squaring.
๐Ÿง  Conceptual
expert
2:00remaining
Understanding list identity after slicing
Consider this code. What is the output of the print statement?
Python
a = [1, 2, 3, 4]
b = a[:]
b[0] = 100
print(a[0])
A100
BTypeError
CIndexError
D1
Attempts:
2 left
๐Ÿ’ก Hint
Slicing creates a new list copy, so changes to b do not affect a.