
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Discover generators in Python by defining a function with yield, which returns a generator object that is iterable with for loops and yields elements you can iterate over.
Explore how the yield statement creates a generator and enables lazy evaluation, executing code only as you iterate, and a new generator object is needed for a second iteration.
Implement a factorial generator in Python by returning a reference to a generator object that yields factorials for numbers one to four, using yield and iteration over the generator.
Create a generator expression with parentheses, mirroring list comprehension syntax, and observe that it yields values from a generator object, as memory use stays low compared to lists.
Explore how a factorial generator is built with a generator expression that yields factorials for numbers one through four, returning a generator object you can iterate.
Assess memory usage and performance by comparing generators and lists, considering data accuracy, object size, and team familiarity to decide practical usage cases.
Explore solutions to every quoting exercise and access short explanatory videos for each solution and coding exercise, with opportunities to request more coding exercises across subtopics.
This course covers one of the more difficult topics in computer programming. Explaining it step by step throughout the course, using code samples and detailed explanation will provide you with the desired in-depth understanding of this topic, not only in Python but in other programming languages as well. The coding exercises this course includes will allow you to assess the level of understanding you achieve. In addition to generators, this course also covers the generator expression topic.
The course starts with a general for the generator class and for the common simple way for getting an object of that type by using the yield statement. The continue with a more detailed explanation for the indirect code changes the compiler introduces when using the yield statement, and for what happens when iterating a generator object. The course continues with explaining how to create a generator expression and explains the main difference between a generator expression and a list comprehension. The course concludes with a short overview of the common cases in which we will probably prefer the use of generators.
This course, like all of our other courses, evolves over time. Taking this course, we will provide you full support, and provide you with additional video clips and slides whenever needed.
Please don't hesitate and let us know if you feed that additional coding exercises will assist, and we will create more of them. Please try to specify the exact sub-topics in which the additional practice is needed.
Please don't hesitate and let us know of any additional sub-topic you would like us to add to this course. We will do our best to fulfill your request.