Print multiples of 7 using yield

Question:
Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n.Use yield.

Program:

Explanation

The yield statement is used to define generators, replacing the return of a function to provide a result to its caller without destroying local variables. Unlike a function, where on each call it starts with new set of variables, a generator will resume the execution where it was left off.

Output:

Leave a Reply

bodrum escort - eskişehir esc - mersin escort - mersin escort bayan - mersin esc