List Quiz: 03
Python Lists Quiz - Set 3
Answer the following questions about Python lists by selecting the correct options:
Time Remaining: 10:00
1. What does this code print?
x = [4, 8, 2]
x.sort(reverse=True)
print(x)
A) [2, 4, 8]
B) [8, 4, 2]
C) [4, 8, 2]
D) Error
2. What will be the result of this code?
x = [1, 2, 3, 2]
x.remove(2)
print(x)
A) [1, 3, 2]
B) [1, 2, 3, 2]
C) [1, 3]
D) Error
3. What will this code output?
x = [10, 20, 30]
x.insert(2, 25)
print(x)
A) [10, 20, 30, 25]
B) [10, 20, 25, 30]
C) [25, 10, 20, 30]
D) Error
4. What does the following code output?
x = [5, 10, 15]
print(len(x))
A) 5
B) 10
C) 3
D) Error
5. What does the following code print?
x = ["a", "b", "c"]
print(x[2])
A) a
B) b
C) c
D) Error
6. What will this code output?
x = [5, 10, 15]
y = x.copy()
y[1] = 20
print(x)
A) [5, 20, 15]
B) [5, 10, 15]
C) Error
D) None
7. What does this code output?
x = [2, 4, 6]
print(min(x))
A) 2
B) 4
C) 6
D) Error
8. What will this code output?
x = [3, 6, 9]
print(x.index(6))
A) 0
B) 1
C) 2
D) Error
9. What will the following code output?
x = [0] * 4
print(x)
A) [0, 4]
B) [4, 4, 4, 4]
C) [0, 0, 0, 0]
D) Error
10. What does the following code output?
x = ["apple", "banana", "cherry"]
print("banana" in x)
A) True
B) False
C) Error
D) None