Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Chaining and Composing Iterators | Python Iterators
Functional Programming Concepts in Python
Avsnitt 5. Kapitel 7
single

single

Challenge: Chaining and Composing Iterators

Svep för att visa menyn

Uppgift

Svep för att börja koda

Implement the function chained_odds_squared(numbers) that chains together the provided generator functions to process a sequence of numbers:

  • First, use the filter_odds generator to filter out even numbers from the input iterable numbers.

  • Then, use the square_numbers generator to yield the square of each remaining (odd) number.

  • Your function should return an iterator that yields the squared values of odd numbers from the input.

  • Do not create intermediate lists.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 7
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt