用input函数设计复利计算公式
时间: 2023-05-30 15:06:45 浏览: 164
matlab贷款计算函数.zip
principal = float(input("请输入本金:"))
rate = float(input("请输入年利率(如0.05):"))
years = int(input("请输入投资年限:"))
compound = int(input("请输入每年复利次数:"))
amount = principal * (1 + rate/compound)**(years*compound)
print("未来{}年后,您的本金{}元将变成{}元。".format(years, principal, round(amount, 2)))
阅读全文