List Quiz: 08
Advanced Python Lists Quiz
Answer the following advanced questions about Python lists:
Time Remaining: 20:00
1. What will this code output?
x = [1, 2, 3, 4, 5]
print(x[::2])
2. What will be the output of this code?
x = [10, 20, 30]
y = [i * 2 for i in x]
print(y[1])
3. What does this code output?
x = [5, 3, 1]
y = x.pop(1)
print(x, y)
4. What will this code output?
x = [2, 4, 6, 8]
x.insert(2, 5)
print(x)
5. What is the output of this code?
x = [1, 2, 3, 4, 5]
y = x[1:4]
print(y)
6. What will this code output?
x = [2, 4, 6, 8]
print(sum(x) / len(x))
7. What does the following code output?
x = [10, 20, 30]
x.append(x[1] + x[2])
print(x)
8. What is the output of this code?
x = [[1, 2], [3, 4]]
print(x[1][1])
9. What does this code output?
x = [3, 5, 7]
y = [9, 8, 7]
z = [a + b for a, b in zip(x, y)]
print(z)
10. What will this code output?
x = [4, 8, 12, 16]
y = [i // 4 for i in x]
print(y)