def somadora():
    qt_parcelas = 0
    total = 0
    try:
        while True:
            parcela = yield
            qt_parcelas += 1
            total += parcela
            print('parcelas: %d  total: %d' % (qt_parcelas, total))

    finally:
        print('parcelas: %d  total: %d  media: %d' % (qt_parcelas, total, total/qt_parcelas))
dataset/ETHPy150Open fluentpython/example-code/attic/control/adder/soma.py/somadora/original