【发布时间】:2020-09-04 13:56:47
【问题描述】:
运行以下代码:
p = int(input("principal: "))
interest = int(input("annual interest rate: "))
years = int(input("# of years: "))
r = interest // 100
n = years * 12
top = r * (1 + r) ** n
bottom = (1+r) ** n - 1
fraction = top // bottom
A = fraction * p
print(A)
我明白了:
line 17, in <module>
fraction = top // bottom
ZeroDivisionError: integer division or modulo by zero
我是初学者,请善待!
【问题讨论】:
-
“ZeroDivisionError:整数除法或模除以零”。正如错误所说,
bottom为 0。请检查其余数据以了解原因。
标签: python calculator