List Basics
Modifying Lists
Loops + Lists
Loop Algorithms
Debugging
100

What is an index? 

The position of an element in a list.

100

You have a list named players. Write a line of code that adds the name "Jordan" to the very end of that list.

players.append("Jordan")

100

Which loop type is best if you only need to read the values and don't care about their positions, value-based or index-based? 

A value-based loop

100

How many times will this loop run?


3 times

100

What is wrong with this code? 

The parenthesis ( ) should be square brackets [ ]

200

In the list fruit = ["apple", "pear", "peach"], what is the index of "pear"?

1

200

If prices = [10, 20, 30], write a line of code that changes the 30 to a 35.

prices[2] = 35

200

What does len(my_list) return if the list is empty?

0

200

Complete this code to find the sum of all numbers in prices: 

total = total + p

or

total += p

200

What is wrong with the following code?

range(drinks): should be range(len(drinks)):

300

Which type of brackets are required to properly define a list in Python?

Square brackets []

300

A program runs items.remove("Laptop"). If "Laptop" is not inside the items list, what happens?

Python will give you a ValueError

300

If you need to change every number in a list to be negative, which loop type should you use, value-based or index-based? 

An index-based loop.

300

Complete the two lines of code to count the number of elements that are above 35 in the scores list.


300

What is logically wrong with this attempt to find the average of a list of grades? 

The line avg = total / len(grades); should be unindented because it should only run once after the loop is done.

400

How would you initialize a variable named my_data so that it starts as a list with no elements inside?

my_data = []

400

Given vals = [5, 10, 15], what code would you write to double the value of the middle element?

vals[1] = vals[1] * 2 

or 

vals[1] *= 2

400

What is the output of this code? 

20

30

400

If you run this code: 

What will be print out?  

0

1

2

3

4

400

Why does print(my_list[len(my_list)]) always cause an error?

Because the len(my_list) is one higher than the final valid index.

500

If len(users) is 50, what is the exact index of the first and last elements of the users list?

 First is 0, last is 49

500

What is the final state of the list colors after these two lines? 

["red", "blue", "red"]

500

Write a loop to print every other element of the tasks list:

500

You are given a list called temperatures. Write a loop that subtracts 5 from every temperature that is currently above 100.

500

To find the minimum value in a list of prices, a student writes the following code: 

 Why does this code not find the correct minimum?

None of the values in the prices list are lower than 0, the initial value of min_price

To make the code work, you can set min_price = prices[0] or to a very large number. 

M
e
n
u