def payper(Rate, NumPeriods, PresentValue, FutureValue, Due):
    """
    Periodic payment of loan or annuity

    :param Rate:            Interest rate per period. Enter as a decimal fraction.
    :param NumPeriods:      Number of payment periods in the life of the instrument.
    :param PresentValue:    Present value of the instrument.
    :param FutureValue:     (Optional) Future value or target value to be attained after NumPeriods periods.
    :param Due:             (Optional) When payments are due: 0 = end of period (default), or 1 = beginning of period.
    :return:


    This example shows how to find the monthly payment for a three-year
    loan of $9000 with an annual interest rate of 11.75%.

    Example:
        >>> Payment = payper(0.1175/12, 36, 9000, 0, 0)
        297.85528322

    """

    x = 1 / (1 + Rate)
    q = (x ** (NumPeriods + 1) - x ) / (x - 1)
    PM = -1 * (FutureValue - PresentValue) / q

    # print "PM = ", PM
    return PM