Hi and Hello, everyone. Welcome to this course on generator and yield statement Python. I'm your facilitator command reserved for this course on generator and yield statement. Let's begin. If already seen the introduction video on generator yield and yield statement keyword, I gave you a brief introduction about that and I hope you have already heard that. So let's go to the next slide.
Definition generally generators are sometimes very difficult to understand. However, actually they are very simple. If we take the right approach, it is a function that generates sequence of values that it trade over and produce results. That is one at a time. This is a very important feature, it produces result that is one at a time Normally a function produces results or it it, it runs the whole function together. However, generator when called upon first time it produces result, the second time it produces results, and it runs the code from where it had left the first time and so on.
So, that's a unique feature in generator and that makes it very useful in when when we are making memory intensive application. So, what is what is a generator it produces a sequence of values that trait over and produce result that is one at a time. So whenever we are looking for reserves, one at a time we can use a generator. And it is very useful especially in case when finite data sets as well or large data set as well. In other words, tonight is a function that can be paused and resumed on the fly. Like it produces result one at a time.
So it can be paused for example, if you want if you're looking for producing first results, we can use the generator function within the for loop that's simple and return an object that can be created over the produce item yield one at a time at only when asked this is the yield keyword using generator and this produces the output. So, whenever there is a huge statement, it produces the output and the next time the generator runs it starts from that point in keyword used to generate value in which case that value is treated as generated value. So that is exactly what I already said. He keyword produces the output and the next time that the generator function is called. It starts from from the point where the use statement is last. Last used Okay,