n=()
是一个有效的Python语句,并没有问题。然而n=()
正在评估n
到一个空的tuple()
。我相信你所要做的是如下。
def FractionDivider(a,b,c,d):
'''
Divides a fraction by another fraction...
'''
n = a #setting each individual parameter to a new name.
d = b #creating a pointer is often useful in order to preserve original data
n2 = C#but it is however not necessary in this function
d2 = d
return (float(n)/d)/(float(n2)/d2) #we return our math, Also order of operations exists here '''1/2/3/4 != (1/2)/(3/4)'''
print FractionDivider(1, 2, 3, 4) #here we print the result of our function call.
#indentation is extremely important in Python
这里是写同样的功能
def FractionDivider_2(n,d,n2,d2):
return (float(n)/d)/(float(n2)/d2)
print FractionDivider_2(1,2,3,4)
请更新你所得到的错误后的simpiler方式。 – AKS