Last Updated: January 3, 2026
29 quizzes
Access the last element of the tasks list without using its length directly
last_task = tasks[]Click an option to fill the blank:
Create a sublist of the first three elements from the scores list
top_three = scores[]Click an option to fill the blank:
Add several new log entries from another list to the end of the existing logs list
logs.(['user_login', 'user_logout'])Click an option to fill the blank:
Which statement correctly creates an empty list to store user IDs?
You need an ordered, changeable collection of product names. Which type is most suitable?
Given prices = [10.0, 20.5, 30.0], which expression accesses 20.5?
What does orders[1:4] return for orders = ['a', 'b', 'c', 'd', 'e']?
Which method removes and returns the last item from a list of messages?
Which list method is best to add a single new task at the end of todo_list?
Which is a valid list comprehension to create a list of doubled values from data?
Given grades = [[80, 90], [70, 75]], what is grades[0][1]?
You have logs = ['start', 'process', 'end']. Which operation changes 'process' to 'process_ok'?
What does this list comprehension build? usernames = [name.lower() for name in raw_names]
Which slicing expression reverses the list history?
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.
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.
What is the output of this code?
1scores = [10, 20, 30, 40]
2print(scores[-2])What is the output of this code?
1data = [1, 2, 3, 4, 5]
2sub = data[1:4]
3print(len(sub))What is the output of this code?
1items = ['a', 'b', 'c']
2items.append('d')
3print(items[2])What is the output of this code?
1numbers = [1, 2, 3, 4]
2result = [n * 2 for n in numbers if n > 2]
3print(result)What is the output of this code?
1matrix = [[1, 2], [3, 4]]
2value = matrix[0][0] + matrix[1][1]
3print(value)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.
def last_three_logs(logs): # Return the last three entries from logs slice_logs = logs[3:] return slice_logsFind 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.
def total_sales(daily_sales): total = 0 for day in daily_sales: total += day return totalMatch 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.
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.
Complete the code to build a list of squared temperatures (in Celsius) that are above freezing from a readings list.
def squared_above_freezing(readings): filtered = for temp in readings: if temp > 0: filtered.(temp ** 2) return filteredClick an option to fill blank 1:
Complete the code to extract the middle row from a 3x3 matrix stored as a nested list and compute its average.
def middle_row_average(matrix3x3): row = matrix3x3[] avg = sum(row) / return avgClick an option to fill blank 1:
Click the line that uses list slicing to skip every other element.
Click on the line to select.
data = [10, 20, 30, 40, 50]first_three = data[:3]step_slice = data[::2]last_two = data[-2:]Click the line that accesses an element from a nested list.
Click on the line to select.
rows = [[1, 2], [3, 4], [5, 6]]second_row = rows[1]value = rows[2][0]length = len(rows)