Python 2.7 我的python代码有问题

Python 2.7 我的python代码有问题,python-2.7,Python 2.7,我似乎无法找出这段代码的错误。我对python和一般的编码都是新手。我一直在寻找其他的解决办法,但由于某种原因,我总是陷入痛苦的循环 x = int(raw_input("Enter the value of the exponent of i.")) y = x / float(4) z = y-int(y) #---------------------- if int(z) == 0(): print "The answer is 1." if int(z) == 0.25():

我似乎无法找出这段代码的错误。我对python和一般的编码都是新手。我一直在寻找其他的解决办法,但由于某种原因,我总是陷入痛苦的循环

x = int(raw_input("Enter the value of the exponent of i."))
y = x / float(4)
z = y-int(y)
#----------------------
if int(z) == 0():
    print "The answer is 1."

if int(z) == 0.25():
    print "The answer is i."

if int(z) == 0.5():
    print "The answer is -1."

if int(z) == 0.75():
    print "The answer is -i."
出于某种原因,我尝试的每件事都会出现以下错误:

Traceback (most recent call last):
File "C:\Users\John\Desktop\I_Exp.py", line 6, in <module>
 if int(z) == 0():
TypeError: 'int' object is not callable
回溯(最近一次呼叫最后一次):
文件“C:\Users\John\Desktop\I\u Exp.py”,第6行,在
如果int(z)==0():
TypeError:“int”对象不可调用
  • 括号用于调用函数或更改python中运算符的优先级,这并不意味着在常量浮点数之后添加()或更改为
    int
    或更改为
    int
  • 当您想在字符串中输出变量时,您应该使用下面的%符号,或者您可以使用逗号分隔字符串和变量,如打印“答案是”,d
你可以这样做:

x = float(raw_input("Enter the value of the exponent of i."))
y = x / 4
z = y-int(y)

if (z == 0):
    print "The answer is 1."

if (z == 0.25):
    print "The answer is %d." % i

if (z == 0.5):
    print "The answer is -1."

if (z == 0.75):
    print "The answer is -%d." % i

你是想打电话给我吗?用来调用某个东西的语法是什么?这可能是错误含义的线索。()用于调用函数,0是
int
对象。我认为您应该先阅读Python的基本语法。