编写 EMI 计算器程序
偷偷努力,悄无声息地变强,然后惊艳所有人!哈哈,小伙伴们又来学习啦~今天我将给大家介绍《编写 EMI 计算器程序》,这篇文章主要会讲到等等知识点,不知道大家对其都有多少了解,下面我们就一起来看一吧!当然,非常希望大家能多多评论,给出合理的建议,我们一起学习,一起进步!
emi 计算器:
emi 计算器可帮助您轻松估算每月分期付款。一旦您输入必要的详细信息,例如贷款金额、贷款期限和利率,银行的 emi 计算器将立即显示您估计的等值每月分期付款 (emi)。
要计算 emi,您可以使用以下公式:
emi = [p x r x ( 1 + r )^n] / [( 1 + r )^n -1]
地点:
p = 本金
r = 月利率(年利率/12个月)
n = 贷款期限(以月为单位)
示例:
# input the loan amount loan = int(input("enter the loan amount: ")) # input the loan tenure in years and convert to months tenure_year = int(input("enter the loan tenure in years: ")) tenure_month = tenure_year * 12 # convert years to months print("loan tenure in months:", tenure_month) # input the interest rate per year and convert to monthly interest rate interest_year = float(input("enter the interest per year: ")) interest_month = interest_year / 12 / 100 # convert annual interest rate to monthly decimal rate print("interest per month in percentage:", interest_month) # calculate emi using the formula emi = loan * (interest_month * (1 + interest_month) ** tenure_month) / ((1 + interest_month) ** tenure_month - 1) # display the calculated emi, rounded to 2 decimal places print("emi:", round(emi, 2))
输出:
Enter the loan amount:500000 Enter the loan tenure in years :10 Loan tenure in months: 120 Enter the interest per year:3.5 Interest per month in percentage: 0.002916666666666667 EMI: 4944.29
今天带大家了解了的相关知识,希望对你有所帮助;关于文章的技术知识我们会一点点深入介绍,欢迎大家关注公众号,一起学习编程~
版本声明 本文转载于:dev.to 如有侵犯,请联系删除