TypeError:“int”对象不可调用
谁知道我该如何修复这个错误?我知道误差在方程式中的某处。谢谢
decimal = 0
rate = 0
principal = 0
years = 0
def simple(p, r, n,):
decimal = r / 100
print("Principal: " + str(p))
print("Rate: " + str(decimal))
print("Number of Years: " + str(n))
total = p (1 + (decimal * n))
print("Total: " + str(total))
def main():
principal = int(input("Enter Principal: "))
rate = float(input("Enter Rate: "))
years = int(input("Enter Numbers of Years: "))
simple(principal, rate, years)
main()
print("End of Program")发布于 2016-04-28 21:07:24
这里的p是您尝试调用的整数:
total = p (1 + (decimal * n))我认为你想要:
total = p*(1 + (decimal * n))发布于 2016-04-28 21:08:24
这一行中的p应该是一个函数,因为它后面紧跟一个圆括号:
total = p (1 + (decimal * n))但是p是作为上面的一个参数传递的,所以我猜你是在传递一个整数。如果你想做乘法:
total = p * (1 + (decimal * n))发布于 2019-05-01 23:09:08
您应该先定义p simple(int p,int r,int t),然后定义total=p*(1+decim
https://stackoverflow.com/questions/36915549
复制相似问题