← Tous les quiz publics
Démarrer le quiz (invité ou compte)
Python — Comprehensions, iterators & generators
par Jude · 23/05/2026 · 5 vues · partages
Comprehensions (list/dict/set), iterator protocol,
yield, generator pipelines and itertools. 20 questions.
20
Questions
🇬🇧 English
Langue
🔴 Difficile
Difficulté
Aperçu des questions
-
1. What does
[x * x for x in range(5) if x % 2]evaluate to? -
2. Difference between
(x for x in r)and[x for x in r]? -
3. What protocol must an iterator implement?
-
4. What does this print?
def gen(): yield 1 yield 2 yield 3 print(sum(gen())) -
5. What is the output?
def gen(): x = yield 1 yield x + 10 g = gen() print(next(g)) print(g.send(5))
… et 15 autres questions.