List Quiz: 02
Python Lists Quiz - Set 2
Answer the following questions about Python lists by selecting the correct options:
Time Remaining: 10:00
1. What does this code print?
x = [5, 10, 15]
x[1] = 20
print(x)
2. What is the result of this code?
x = [10, 20, 30, 40]
print(x[1:3])
3. What will be the result of the following code?
x = [5, 10, 15]
print(x * 2)
4. What does the following code output?
x = [1, 2, 3]
x.extend([4, 5])
print(x)
5. What does the following code return?
x = [10, 20, 30, 40]
print(x.index(30))
6. What does this code print?
x = [1, 2, 3]
x.pop()
print(x)
7. What will this code output?
x = [2, 3, 1, 5]
x.sort()
print(x)
8. What does this code output?
x = ["apple", "banana", "cherry"]
print(x[::-1])
9. What is the output of this code?
x = [1, 2, 3]
print(sum(x))
10. What does this code output?
x = [1, 2, 3]
x.clear()
print(x)