In: Computer Science
implement a formula of your own choosing, as a Python function, following these instructions:
Thanks for the question, here is a financial function, that takes in the loan amount, annual interest rate and number of years and calculates the monthly interest rate and returns the monthly interest rate.
=============================================================
# function calculates monthly interest
# functions takes in loan amount, annual interest rate , total
number of years
def
calculate_monthly_interest(loan_amount,annual_interest,years):
monthlyRate=annual_interest/1200
months=years*12
monthly_payment = loan_amount * ((monthlyRate *
((1 + monthlyRate) ** months)) / ((1 + monthlyRate) ** months -
1))
return monthly_payment
def main():
loan_amount = float(input('Enter Loan
Amount: '))
rate = float(input('Enter annual
interest rate (%): '))
years = float(input('Enter number of
years: '))
monthly_interest=
calculate_monthly_interest(loan_amount,rate,years)
print('Your monthly interest will be
:${0:.2f}'.format(monthly_interest))
main()