在这里,我有以下尝试以计算复杂的利息和抵押贷款利息为例。但是,它在 TotalMonthsMortgage = TotalMonthsMortgage - 1.0 上给出了语法错误,标记第一个 TotalMonthsMortgage / 左侧的那个 / 如果我引用它,它标记下一行 AlreadyPaidAmount = AlreadyPaidAmount+TotalAmountMortgage/TotalMonthsMortgage 标记左侧的 AlreadyPaidAmount。我做错了什么,因为我自己找不到错误?
## Complicated interest is the bank interest for example charged for mortgage loans
TotalAmountMortgage = float(raw_input('Enter the total amount of the mortgage to be taken:')) ##this is Principal
TotalYearsMortgage = float(raw_input('Enter the number of total years of the mortgage to be taken:'))
TotalMonthsMortgage = float(TotalYearsMortgage*12.0)
TotalYearsFixedInterest = float(raw_input('Enter the number of years with fixed interest mortgage to be taken:'))
TotalMonthsFixedInterest = 12.0*TotalYearsFixedInterest
FixedInterest = float(raw_input('Enter fixed interest for the mortgage to be taken:'))
FloatingInterest = float(raw_input('Enter floating interest for the mortgage to be taken:'))
PoolInterestPaid = 0.0
MonthlyPayment = 0.0
AlreadyPaidAmount = 0.0
FixedPayment = float(TotalAmountMortgage/TotalMonthsMortgage)
TotalPayment = float
while (TotalMonthsMortgage-TotalMonthsFixedInterest)>0:
MonthlyPayment = FixedPayment+(TotalAmountMortgage-((FixedPayment*TotalMonthsFixedInterest+AlreadyPaidAmount))*FloatingInterest/1200
TotalMonthsMortgage = TotalMonthsMortgage - 1.0
AlreadyPaidAmount = AlreadyPaidAmount+TotalAmountMortgage/TotalMonthsMortgage
TotalPayment = (TotalAmountMortgage*FixedInterest*TotalMonthsFixedInterest)/TotalMonthsMortgage+(TotalAmountMortgage*TotalMonthsFixedInterest)/TotalMonthsMortgage+PoolInterestPaid
print TotalPayment ##This is the total amount to be paid
print (TotalPayment - TotalAmountMortgage) ##This is the amount of intererst to be paid over time
print (TotalPayment - TotalAmountMortgage)/TotalMonthsMortgage ##This is the amount of monthly payment