使用一组输入值和固定利率构建计算器

Building a calculator with set of input values and fixed interest rate

假设,我是 运行 每周业务,每周以 5% 的固定利率每周获利,并假设我的投资每周递归,我想打印前 21 个的所有值周。我如何在 python 中修改代码以实现此目的? 注意:投资是递归的,(即)每周我的投资将是之前的投资加上那一周的利润,而且我正在四舍五入这些值并且我已经编写了这段代码但是对于循环我正在努力编写逻辑,可以请有人帮忙。我在 excel 中编写了逻辑/计算 - 请检查 excel 屏幕截图中的预期结果。

maximum_number_of_weeks = int(input("maximum_number_of_weeks:"))
Initial_investment_Amount = int(input("Enter Initial Investment Amount Value ($) : "))
Interest_rate = float(input("Enter Interest Rate Value (%) : "))
Amount_Earned = Initial_investment_Amount * Interest_rate
Total_Amount_at_Disposal = Initial_investment_Amount + Amount_Earned
print("Total_Amount_at_Disposal ($) : ",Total_Amount_at_Disposal)

我建议使用更简单的方法:

可支配金额=初始投资*(1+利率)^(周数)

maximum_number_of_weeks = int(input("maximum_number_of_weeks:"))
Initial_investment_Amount = int(input("Enter Initial Investment Amount Value ($) : "))
Interest_rate = float(input("Enter Interest Rate Value (%) : "))

for week in range(1, maximum_number_of_weeks + 1):
    Total_Amount_at_Disposal = Initial_investment_Amount * (1 + Interest_rate/100) ** week
    print("Total_Amount_at_Disposal ($) : ",round(Total_Amount_at_Disposal, 2))