美图齐众专注资阳网站设计 资阳网站制作 资阳网站建设
资阳网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Python程序:计算复利

创新互联python教程:

我们提供的服务有:成都网站设计、成都做网站、微信公众号开发、网站优化、网站认证、海城ssl等。为上千多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的海城网站制作公司

用例子写一个计算复利的 Python 程序。在我们开始 Python 复利程序之前,让我向您展示复利背后的公式:

未来 CI =本金金额* ( 1 + ROI ) 年数 )

上述计算称为未来复利。因为它包含本金和配置项。获取复利:复利=未来配置项-本金

计算复利的 Python 程序

这个 python 程序允许用户输入本金金额、利率和时间段(年数)。使用这些值, Python 使用上面指定的公式计算复利。

import math

princ_amount = float(input(" Please Enter the Principal Amount : "))
rate_of_int = float(input(" Please Enter the Rate Of Interest   : "))
time_period = float(input(" Please Enter Time period in Years   : "))

ci_future = princ_amount * (math.pow((1 + rate_of_int / 100), time_period)) 
compound_int = ci_future - princ_amount

print("Future Compound Interest for Principal Amount {0} = {1}".format(princ_amount, ci_future))
print("Compound Interest for Principal Amount {0} = {1}".format(princ_amount, compound_int))


当前题目:Python程序:计算复利
分享链接:http://www.zsjierui.cn/article/cdpidpi.html

其他资讯