Skip to main content

List Quiz: 06

Mejbah Ahammad

Python Lists Quiz - Extreme Level

Python Lists Quiz - Extreme Level

Answer the following expert-level questions about Python lists:

Time Remaining: 10:00

1. What does this code output?

x = [i for i in range(5) if i % 2 == 0]
x = [i**2 for i in x]
print(sum(x))

2. What does this code output?

x = [lambda i=i: i for i in range(5)]
print([f() for f in x])

3. What will this code output?

x = [[j for j in range(i)] for i in range(3, 6)]
print(x)

4. What does this code output?

x = [10, 20, 30]
_, *y, _ = x
print(y)

5. What does this code output?

x = [i for i in range(10) if i % 3 == 0]
print(x[1:][::-1])

6. What will this code output?

x = [1, 2, 3]
y = (i for i in x)
print(list(y) == list(y))

7. What does this code output?

x = [1, 2, 3, 4]
y = x[-1::-2]
print(y)

8. What does this code output?

x = [[j for j in range(2)] for i in range(3)]
x[0][1] = 5
print(x)

9. What does this code output?

x = [1, 2, 3]
y = [4, *x, 5]
print(y)

10. What does this code output?

x = [1, 2, 3]
print(all([i < 5 for i in x]))