Python list comprehensions offer a concise way to create lists using loops and conditions in a single line. This quiz helps you master list comprehension syntax, nested comprehensions, and filtering for efficient Python programming.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the equivalent of this list comprehension?
squares = [x*x for x in range(4)]
Correct
Incorrect
Question 3 of 15
3. Question
What will this return?
[x for x in range(10) if x % 2 == 0]
Correct
Incorrect
Question 4 of 15
4. Question
Which is the correct syntax for list comprehension?
Correct
Incorrect
Question 5 of 15
5. Question
What will this produce?
[char.upper() for char in “data”]
Correct
Incorrect
Question 6 of 15
6. Question
Which comprehension returns a list of squares for numbers divisible by 3 in range(10)?
Correct
Incorrect
Question 7 of 15
7. Question
How do you flatten a 2D list using list comprehension?
matrix = [[1, 2], [3, 4]]
Correct
Incorrect
Question 8 of 15
8. Question
What will be the output?
[True if x > 0 else False for x in [-1, 0, 1]]
Correct
Incorrect
Question 9 of 15
9. Question
What is the output of this code?
[x*y for x in [1, 2] for y in [10, 20]]
Correct
Incorrect
Question 10 of 15
10. Question
Which list comprehension returns the string lengths?
words = [“Python”, “is”, “fun”]
Correct
Incorrect
Question 11 of 15
11. Question
Which list comprehension filters numbers greater than 5?
Correct
Incorrect
Question 12 of 15
12. Question
What happens when you use list comprehension with range(0)?
Correct
Incorrect
Question 13 of 15
13. Question
What is the result of this comprehension?
[x+1 for x in [0, 1, 2]]
Correct
Incorrect
Question 14 of 15
14. Question
List comprehension is generally:
Correct
Incorrect
Question 15 of 15
15. Question
Which of the following is not a benefit of list comprehension?
Correct
Incorrect
Summary
List comprehensions in Python let you build lists faster, cleaner, and with less code. This quiz tested your understanding of syntax, filtering, conditionals, and nested comprehensions — all critical for writing modern Pythonic code.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.