What is an index?
The position of an element in a list.
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")
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
How many times will this loop run?

3 times
What is wrong with this code?

The parenthesis ( ) should be square brackets [ ]
In the list fruit = ["apple", "pear", "peach"], what is the index of "pear"?
1
If prices = [10, 20, 30], write a line of code that changes the 30 to a 35.
prices[2] = 35
What does len(my_list) return if the list is empty?
0
Complete this code to find the sum of all numbers in prices:

total = total + p
or
total += p
What is wrong with the following code?

range(drinks): should be range(len(drinks)):
Which type of brackets are required to properly define a list in Python?
Square brackets []
A program runs items.remove("Laptop"). If "Laptop" is not inside the items list, what happens?
Python will give you a ValueError
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.
Complete the two lines of code to count the number of elements that are above 35 in the scores list.


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.
How would you initialize a variable named my_data so that it starts as a list with no elements inside?
my_data = []
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
What is the output of this code?

20
30
If you run this code:

What will be print out?
0
1
2
3
4
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.
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
What is the final state of the list colors after these two lines?

["red", "blue", "red"]
Write a loop to print every other element of the tasks list:


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

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.