Jupyter打印声明问题

时间:2019-12-13 15:37:27

标签: python jupyter

我正在用Jupiter写我的第一个程序(请注意我没有编程经验),我写了下面的程序来简单地打印工资,但是我遇到了以下错误消息?有人可以指导我我在做什么错

# Worked Exercise: 2.3

#my first program to get name and calc pay rate

name = input("Enter your name")
print = ("Hello ",name)

hour = input("Enter number of hours: ")
p_rate = input("Enter Pay rate: ")

pay = float(hour) * float(p_rate)

print("Calculated Salary is ",pay)
#pay <- this works, however, fails if I use print statement

我收到以下错误消息

TypeError                                 Traceback (most recent call last)
<ipython-input-10-50753a76d716> in <module>
     12 #pay
     13 
---> 14 print("Calculated Salary is ",pay)

TypeError: 'tuple' object is not callable

2 个答案:

答案 0 :(得分:2)

在我看来,您不小心创建了一个名为print的元组,并且调用了该元组而不是print()函数。

最有可能是通过键入print = ("Calculated Salary is ",pay)或类似的内容来实现的。

使用del print删除您创建的元组。
del从内存中删除内容。

当在控制台中使用python时(例如在Jupyter中),必须注意在新说明之前声明的内容。

答案 1 :(得分:0)

print =(“ Hello”,name)

是您的代码中的错误。 删除将解决问题。

相关问题