AlgoMaster Logo

Lists - Quiz

Last Updated: January 3, 2026

Lists Exercises

29 quizzes

1
Code Completion

Access the last element of the tasks list without using its length directly

python
1
last_task = tasks[]

Click an option to fill the blank:

2
Code Completion

Create a sublist of the first three elements from the scores list

python
1
top_three = scores[]

Click an option to fill the blank:

3
Code Completion

Add several new log entries from another list to the end of the existing logs list

python
1
logs.(['user_login', 'user_logout'])

Click an option to fill the blank:

4
Multiple Choice

Which statement correctly creates an empty list to store user IDs?

5
Multiple Choice

You need an ordered, changeable collection of product names. Which type is most suitable?

6
Multiple Choice

Given prices = [10.0, 20.5, 30.0], which expression accesses 20.5?

7
Multiple Choice

What does orders[1:4] return for orders = ['a', 'b', 'c', 'd', 'e']?

8
Multiple Choice

Which method removes and returns the last item from a list of messages?

9
Multiple Choice

Which list method is best to add a single new task at the end of todo_list?

10
Multiple Choice

Which is a valid list comprehension to create a list of doubled values from data?

11
Multiple Choice

Given grades = [[80, 90], [70, 75]], what is grades[0][1]?

12
Multiple Choice

You have logs = ['start', 'process', 'end']. Which operation changes 'process' to 'process_ok'?

13
Multiple Choice

What does this list comprehension build? usernames = [name.lower() for name in raw_names]

14
Multiple Choice

Which slicing expression reverses the list history?

15
Sequencing

Order the steps to create a list of squared even numbers from an existing list numbers using a list comprehension, then show how many squares were created.

Drag and drop to reorder, or use the arrows.

16
Sequencing

Order the steps to build a nested list representing a 2x2 grid initialized with zeros and then update one cell.

Drag and drop to reorder, or use the arrows.

17
Output Prediction

What is the output of this code?

1scores = [10, 20, 30, 40]
2print(scores[-2])
18
Output Prediction

What is the output of this code?

1data = [1, 2, 3, 4, 5]
2sub = data[1:4]
3print(len(sub))
19
Output Prediction

What is the output of this code?

1items = ['a', 'b', 'c']
2items.append('d')
3print(items[2])
20
Output Prediction

What is the output of this code?

1numbers = [1, 2, 3, 4]
2result = [n * 2 for n in numbers if n > 2]
3print(result)
21
Output Prediction

What is the output of this code?

1matrix = [[1, 2], [3, 4]]
2value = matrix[0][0] + matrix[1][1]
3print(value)
22
Bug Spotting

Find the bug in this code that extracts the last three log entries from a list.

Click on the line(s) that contain the bug.

python
1
def last_three_logs(logs):
2
    # Return the last three entries from logs
3
    slice_logs = logs[3:]
4
    return slice_logs
23
Bug Spotting

Find the bug in this code that sums all values in a nested list of daily_sales.

Click on the line(s) that contain the bug.

python
1
def total_sales(daily_sales):
2
    total = 0
3
    for day in daily_sales:
4
        total += day
5
    return total
24
Matching

Match each list method with what it does when managing a shopping cart list.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

25
Matching

Match each list-related concept with its example.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

26
Fill in the Blanks

Complete the code to build a list of squared temperatures (in Celsius) that are above freezing from a readings list.

python
1
def squared_above_freezing(readings):
2
filtered =
3
for temp in readings:
4
if temp > 0:
5
filtered.(temp ** 2)
6
return filtered

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the code to extract the middle row from a 3x3 matrix stored as a nested list and compute its average.

python
1
def middle_row_average(matrix3x3):
2
row = matrix3x3[]
3
avg = sum(row) /
4
return avg

Click an option to fill blank 1:

28
Hotspot Selection

Click the line that uses list slicing to skip every other element.

Click on the line to select.

python
1
data = [10, 20, 30, 40, 50]
2
first_three = data[:3]
3
step_slice = data[::2]
4
last_two = data[-2:]
29
Hotspot Selection

Click the line that accesses an element from a nested list.

Click on the line to select.

python
1
rows = [[1, 2], [3, 4], [5, 6]]
2
second_row = rows[1]
3
value = rows[2][0]
4
length = len(rows)