List Quiz: 09
Challenging Python Lists Quiz
Answer the following complex 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 is the output of this code?
x = [[i for i in range(3)] for j in range(3)]
print(x[2][0] + x[1][1])
3. What does this code output?
x = [1, 2, 3, 4]
y = [a * b for a, b in zip(x, x[::-1])]
print(y[1])
4. What will this code output?
x = [1, 2, 3]
y = [i**2 for i in x if i % 2 == 1]
print(y)
5. What does this code output?
x = [5, 10, 15]
y = [i / 5 for i in x]
print(sum(y))
6. What will this code output?
x = [[i, i**2] for i in range(3)]
print(x[1][1])
7. What does this code output?
x = [i for i in range(10) if i % 3 == 0]
print(x[::-2])
8. What will this code output?
x = ["apple", "banana", "cherry"]
y = [fruit[1] for fruit in x]
print("".join(y))
9. What does this code output?
x = [1, 2, 3, 4, 5]
y = [lambda a: a * n for n in x]
print(y )
10. What will this code output?
x = [1, 2, 3]
y = [x[i] for i in range(len(x))]
y[1] = 5
print(x, y)