List Quiz: 04
Python Lists Quiz - Advanced
Answer the following questions about Python lists by selecting the correct options:
Time Remaining: 10:00
1. What does this code output?
x = [i**2 for i in range(4)]
print(x)
2. What does this code output?
x = [[1, 2], [3, 4]]
print(x[1][0])
3. What does this code output?
x = [0, 1, 2, 3, 4]
print(x[::2])
4. What does the following code output?
x = [1, 2, 3]
y = [4, 5]
print([a + b for a, b in zip(x, y)])
5. What does this code output?
x = [10, 20, 30, 40]
print(x[-3:-1])
6. What will be the result of this code?
x = [5, 3, 8, 6]
y = sorted(x)
print(y == x)
7. What will this code output?
x = [1, 2, 3]
y = x
y += [4]
print(x)
8. What does this code output?
x = [i for i in range(5) if i % 2 == 0]
print(x)
9. What does this code output?
x = [1, [2, 3], 4]
x[1][0] = 5
print(x)
10. What does this code output?
x = [[i, i**2] for i in range(3)]
print(x)