Python's "yield" keyword: What is it and how does it work?

My teacher has shared some coding examples in which I have found one function that contains the yield keyword. I don’t know about it much and how it works. The code is attached below:

Can someone explain the above code and share with me the flow of the yield keyword?