1. What is a generator in python???

    Simply speaking, a generator is a function that returns an object (iterator) which we can iterate over (one value at a time).

  2. Difference between generator function and object???

    For generator function:

    If the body of a def contains yield, the function automatically becomes a generator function.

    Example:

    **def** simpleGeneratorFun():
    	**yield** 1
    	**yield** 2
    	**yield** 3
    

    For generator object:

    Generator functions return a generator object.

    Example:

    **for** value **in** simpleGeneratorFun():
    	**print**(value)
    

    or

    x = simpleGeneratorFun()
    while True:
        try:
            print(x.next())
        except StopIteration:
            break
    
  3. Why we use generator???