0
대출 비용을 계산하는 함수를 작성하려고하지만 대출 비용을 사용자가 입력 한 금액의 음수 값으로 유지합니다. 차관.함수의 다중 매개 변수 정의 Python
#define monthly payment
def MonthlyPayment (ammountOfLoan, numberOfPeriods,yearlyInterestRate):
ammountOfLoan = 0
numberOfPeriods = 0
yearlyInterestRate = 0
payment = [(yearlyInterestRate/12)/(1-(1+yearlyInterestRate/12))**(-numberOfPeriods)] * ammountOfLoan
return (payment)
#define cost of loan
def LoanCost(principal, month, payment):
period = 0
month = 0
payment = 0
cost = period * payment - principal
return (cost)
#calculate cost of loan
def main():
loan = float(raw_input("What is the ammount of your loan? "))
period = float(raw_input("How many months will you make payments? "))
rate = float(raw_input("What is the interest rate? "))
rate = rate/100
MonthlyPayment(loan, period, rate)
costOfLoan = LoanCost(loan, period, rate)
print "The cost of the loan is $" + str(costOfLoan)
#run main
main()
'pdb'는 친구입니다 – shx2
그냥 값을 바로 버리려면 왜 인수에 합격하겠습니까? (예를 들어'numberOfPeriods = 0'을 실행함으로써). 당신은 파이썬의 기초를 정말로 넘어야합니다. 튜토리얼, 워드 프로세서, 파이썬을 어려운 방법, 코드 아카데미, 기타로 배우십시오. – acushner