File "first.py", line 37
elif(operation == "quadratic formula")
IndentationError: unindent does not match any outer indentation level
我真的不知道我的代碼出現了什麼問題。有人可以幫忙嗎?IndentationError:unindent不匹配任何外部縮進級別
def add(var1, var2):
return var1 + var2
def sub(num1, num2):
return num1 - num2
def div(num1, num2):
return num1/num2
def mul(num1,num2):
return num1*num2
def equation1():
import math
a = int(raw_input("please enter your a in the equation: "))
b = int(raw_input("please enter your b in the equation: "))
c = int(raw_input("please enter your c in the equation: "))
d = b**2-4*a*c
if(d < 0):
print "This equation has no real solution"
elif(d == 0):
x = (-b+math.sqrt(b**2-4*a*c))/(2*a)
print "This equation has one solutions: ", x
else:
x1 = (-b+math.sqrt(b**2-4*a*c))/(2*a)
x2 = (-b-math.sqrt(b**2-4*a*c))/(2*a)
print "This equation has two solutions"
print "The first soluition: ", x1
print "And the second solution", x2
def main():
operation = raw_input("what do you want to do (+,-,/,*) or quadratic
formula? ")
if(operation != '+' and operation != '-' and operation != '/' and operation != '*' and operation != 'quadratic formula'):
print 'You must put a valid operation'
elif(operation == "quadratic formula"):
equation1()
else:
var1 = int(raw_input("enter the first number: "))
var2 = int(raw_input("enter the second number: "))
if(operation == '+'):
print (add(var1, var2))
elif(operation == '/'):
print (div(var1, var2))
elif(operation == '-'):
print (sub(var1, var2))
停止混合標籤和空格。另外,C與這些沒有任何關係。 – user2357112