Skip to main content

List Quiz: 10

Mejbah Ahammad

Advanced Python Lists Quiz

Advanced Python Lists Quiz

Answer the following highly challenging Python list questions:

Time Remaining: 20:00

1. What will this code output?

x = [i**2 for i in range(1, 10, 2)]
print(x[3])

2. What is the output of this code?

x = [sum([j for j in range(i)]) for i in range(5)]
print(x)

3. What does this code output?

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

4. What will this code output?

x = [1, 2, 3]
y = [(lambda a: a + i)(i) for i in x]
print(y)

5. What does this code output?

x = [i for i in range(5)]
y = [a * b for a, b in zip(x, x[::-1])]
print(max(y))

6. What will this code output?

x = [1, 2, 3, 4]
y = x[::-2]
z = [i ** 2 for i in y]
print(z)

7. What does this code output?

x = [1, 3, 6]
y = [i**0.5 for i in x if i % 3 == 0]
print(sum(y))

8. What will this code output?

x = ["apple", "banana", "cherry"]
y = "".join([fruit[-2] for fruit in x])
print(y)

9. What does this code output?

x = [2, 4, 6, 8]
y = [[i, i**2] for i in x]
print(y[1][1])

10. What will this code output?

x = [10, 20, 30]
y = x[:]
y[1] = 99
print(x, y)