尝试将列表项(preclc)传递到一个简单函数中。尝试将列表转换为元组版本(calc),然后调用函数
获取错误消息:TypeError:“tuple”对象不可调用
如何将inputs()传递到函数中
def calc(x,y,z):
a = x * (1 + (y/100))
b = a * (1 - (z/100))
c = (b / 12)
d = x * (1 - (z/100)) / 12
print("the annual gross salary is %.2f" %(x),"kEUR")
print("the annual bonus opportunity is %.2f" %(y), "%")
print("the annual gross salary plus bonus is %.2f" %(a), "kEUR")
print("you have to pay around %.2f" %(z),"% in tax")
print("the annual net salary incl. bonus is %.2f" %(b),"kEUR")
print("The average monthly post-tax salary incl. bonus is %.2f" %(c),"kEUR")
print("The average monthly post-tax salary excl. bonus is %.2f" %(d),"kEUR")
PreCalc = [0,0,0]
PreCalc[0] = int(input("please enter your annual gross salary"))
PreCalc[1] = int(input("please enter your bonus opportunity in %"))
PreCalc[2] = int(input("please enter your tax rate in %"))
print(PreCalc)
calc = tuple(PreCalc)
print(calc)
calc()
您不需要将列表转换为元组
正如评论所说的,不要隐藏calc函数
你也不需要使用列表,你可以这样做
相关问题 更多 >
编程相关推荐