我正在学习基本的Python。我无法执行此代码

我正在学习基本的Python。我无法执行此代码,python,floating-point,Python,Floating Point,我正在学习基本的Python。我无法执行此代码: n=0 current_savings = 0.0 while current_savings<7500.0: current_savings = 1000.0 + (4/12/100*current_savings) print(current_savings) n = n+1 print(n) n=0 当前储蓄=0.0 虽然当前节省我相信您正在尝试在每次迭代后更新当前节省的值: n=0 current_savi

我正在学习基本的Python。我无法执行此代码:

n=0
current_savings = 0.0
while current_savings<7500.0:
    current_savings = 1000.0 + (4/12/100*current_savings)
    print(current_savings)
    n = n+1
print(n)
n=0
当前储蓄=0.0

虽然当前节省我相信您正在尝试在每次迭代后更新当前节省的值:

n=0
current_savings = 0.00
while current_savings<7500.0:
    current_savings = current_savings + (1000.0 + (4/12/100*current_savings))
    print(current_savings)
    n = n+1
print(n)
n=0
当前储蓄=0.00

虽然目前的储蓄我认为这是一个无限循环

n=0
current_savings = 0.0
while current_savings<7500.0:
    current_savings = 1000.0 + (4/12/100*current_savings)
    print(n,current_savings)
    n = n+1
    if n==5:
        break

你期望的结果是什么?
当前储蓄的值收敛于~1003.35。(为什么)这不是你所期望的吗?@KonradRudolph实际上它更接近1003.34(它是1003.34448…)
0 1000.0
1 1003.3333333333334
2 1003.3444444444444
3 1003.3444814814815
4 1003.3444816049383