print("Welcome to calculator.py")
print ("your options are :")
print ("")
print ("1) Addition")
print ("2)Subtraction")
print ("3) Multiplication")
print ("4)Division")
print ("Choose your option")
#this adds 2 numbers given
def add (a,b):
print(a, "+" ,b, "=" ,a+b)
#this subtracts 2 numbers given
def sub (a,b):
print(a, "-" ,b, "=" ,b-a)
#this multiplies 2 numbers given
def mul(a,b):
print(a, "*" ,b, "=" ,a*b)
#this divides 2 numbers given
def div(a,b):
def div(a, "/" ,b, "=" ,a/b)
#NOW THE PROGRAM REALLY STARTS ,AS CODE IS RUN
loop = 1
choice = 0
while loop == 1:
choice = menu()
if choice == 1:
add (input("Add this: "),input ("to this: "))
elif choice == 2:
sub(input("Subtract this: "),input ("from this: "))
elif choice == 3:
mul (input("Multiply this: "),input ("by this: "))
elif choice == 4:
div(input("Divide this: "),input ("by this: "))
elif choice ==5:
loop = 0
print ("Thank you for using calculator.py")
這是我的代碼和錯誤是: 打印(一, 「+」,B, 「=」,A + B) ^ IndentationError:預期的縮進塊這是什麼indentationError?
過程與出口完成代碼1 和許多其他人都可以幫助我找到所有的錯誤? 任何人都可以幫我嗎?
你需要(後'DEF)縮進:'和在其他地方(基本上總是後一個冒號':'),你也需要在一些地方解除縮進 –