← Quiz: Comprehensions and Lambda: all 15 questions
Quiz: Comprehensions and Lambda · Question 14 of 15
What does this print? (code)
What does this print?
print([n * n for n in range(1, 6) if n % 2 == 1])
- A.[1, 4, 9, 16, 25]
- B.[4, 16]
- C.[1, 3, 5]
- D.[1, 9, 25]
Answer & explanation
Correct answer: [1, 9, 25]
Only odd n (1, 3, 5) pass the filter, and each is squared.
Can you get the rest right without peeking?
Take the timed Quiz: Comprehensions and Lambda quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →