Challenge - 5 Problems
List Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ Predict Output
intermediate2: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)
Attempts:
2 left
๐ก Hint
Remember that strings and numbers are different types and are shown with quotes or without.
โ Incorrect
The list contains an integer 1, a string '2', a float 3.0, and a boolean True. The print shows them exactly as stored.
โ Predict Output
intermediate2: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))
Attempts:
2 left
๐ก Hint
len() counts the top-level items in the list, not inside nested lists.
โ Incorrect
The list has three items: 1, [2, 3], and 4. The nested list counts as one item.
โ Predict Output
advanced2: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)
Attempts:
2 left
๐ก Hint
Multiplying a list with nested lists copies references, not independent copies.
โ Incorrect
All three elements point to the same inner list. Changing one changes all.
โ Predict Output
advanced2: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)
Attempts:
2 left
๐ก Hint
The condition filters only even numbers before squaring.
โ Incorrect
Only 0, 2, and 4 are even in range(5). Their squares are 0, 4, and 16.
๐ง Conceptual
expert2: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])
Attempts:
2 left
๐ก Hint
Slicing creates a new list copy, so changes to b do not affect a.
โ Incorrect
b is a copy of a. Changing b[0] does not change a[0]. So a[0] remains 1.