Variables and Assignment - Test

1. How do you remove an element 4 from a list my_list = [1, 2, 3, 4]?

A) my_list.pop(4)
B) my_list.delete(4)
C) my_list.remove(4)

2. What are lists used for in Python?

A) To store a collection of values in an ordered way
B) To perform mathematical calculations
C) To create functions

3. How do you access the last element of a list my_list = [1, 2, 3, 4, 5]?

A) my_list[-1]
B) my_list[len(my_list)]
C) my_list.last()

4. How do you define a list in Python?

A) my_list = [1, 2, 3]
B) my_list = (1, 2, 3)
C) my_list = {1, 2, 3}

5. How do you print the second element of a list my_list = [1, 2, 3, 4, 5]?

A) print(my_list[2])
B) print(my_list[1])
C) print(my_list.second)

6. How do you modify an element in a list list1 = [1, 2, 3] and set the tirth element to 999?

A) list1[1] = 999
B) list1[2] = 999
C) list1.add(999)

7. How do you append an element 4 to a list my_list = [1, 2, 3]?

A) my_list.add(4)
B) my_list.append(4)
C) my_list.insert(4)

8. How do you find the length of a list my_list = [1, 2, 3, 4, 5]?

A) count(my_list)
B) my_list.length()
C) len(my_list)