求一个编好的python程序,十万火急!

1个回答

  • '''

    Created on 2011-9-14

    @author: legendxx

    '''

    rate =0.04

    if __name__ == '__main__':

    amount = int(raw_input("What is amount of loan?"))

    year = int (raw_input("Number of years to pay off the loan?"))

    interest = amount*rate*year

    total = amount + interest

    monthly_payment = total/(year*12)

    print "Monthly payment is:%.2f"%monthly_payment

    print "Total interest paid:%.2f"%interest

    print "Total amount paid:%.2f"%total

    可在2.x环境下运行,与3.x不兼容的,使用的时候请注意.

    另外,利息的公式是按照提供的公式计算的,实际银行采用的是复利,应该比这个实际利率要高.