List Quiz: 01
Python Lists Quiz
Answer the following questions about Python lists by selecting the correct options:
Time Remaining: 10:00
1. What will be printed by the following code?
my_list = [1, 2, 3, 4]
print(my_list[-1])
2. What will the following code output?
x = [1, 2, 3]
y = x
y.append(4)
print(x)
3. What will the following code output?
x = [1, 2, 3]
y = x.copy()
y.append(4)
print(x)
4. What is the output of this code?
x = [10, 20, 30]
print(x[1:])
5. What will be the output of the following code?
x = [1, 2, 3] + [4, 5]
print(x)
6. What will be printed by the following code?
x = [1, 2, 3]
x.insert(1, 4)
print(x)
7. What will be the result of this code?
x = [1, 2, 3, 4, 5]
del x[2]
print(x)
8. What does the following code output?
x = [1, 2]
y = x * 3
print(y)
9. What will this code output?
x = [10, 20, 30]
x.remove(20)
print(x)
10. What will be the output of this code?
x = [1, 2, 3]
print(x.pop(1))