To call a function, you must add parens after the function name, as well as any required parameters.
In these two lines
minMonPay = minimumMonthlyPayment monInt = monthlyInterest
you assign functions to the names minMonPay, monInt, but you donβt actually call them. Rather, you need to write something like:
minMonPay = minimumMonthlyPayment(previousBalance) monInt = monthlyInterest(monthlyInterestRate)
This definition
def minimumMonthlyPayment(previousbalance): return (previousbalance * monthlyPaymentRate)
gives you a function that takes one parameter and calls its previousBalance. This has nothing to do with the variable you created earlier in your code. In fact, I suggest you rename it, it can only confuse you as a beginner.
In addition, the functions you created are so simple and used only once that it may be in your interest to delete them and embed the code.
# OLD CODE def minimumMonthlyPayment(previousbalance): return (previousbalance * monthlyPaymentRate) def monthlyInterest(monthlyInterestRate): return (1 + monthlyInterestRate) minMonPay = minimumMonthlyPayment monInt = monthlyInterest
Remember to update the line that uses the minimumMonthlyPayment function incorrectly if you do.
# OLD CODE print ('Minimum monthly payment: $ ' (round(minimumMonthlyPayment, 2)))
source share