fork download
  1. #Returns the sum of num1 and num2
  2. def add(num1, num2):
  3. return num1 + num2
  4.  
  5. #Returns the result of subtracting num1 - num2
  6. def sub(num1, num2):
  7. return num1 - num2
  8.  
  9. #Returns the result of multiplying num1 * num2
  10. def mul(num1, num2):
  11. return num1 * num2
  12.  
  13. #Returns the result of dividing num1 / num 2
  14. def div(num1, num2):
  15. return num1 / num2
  16.  
  17.  
  18. def main():
  19. operation = input("What do you want to do (+,-,*,/):")
  20. if(operation != '+' and operation != '-' and operation != '*' and operation != '/'):
  21. #invalid operation
  22. print ("You must enter a valid operation")
  23. else:
  24. var1 = int(input("Enter num1: "))
  25. var2 = int(input("Enter num2: "))
  26. if (operation == '+'):
  27. print(add(var1, var2))
  28. elif(operation == '/'):
  29. print (div(var1, var2))
  30. elif(operation == '-'):
  31. print(sub(var1, var2))
  32. else:
  33. print (mul(var1, var2))
  34.  
  35. main()
Runtime error #stdin #stdout #stderr 0.03s 126528KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
  File "<string>", line 35
    main()
         ^
IndentationError: unindent does not match any outer indentation level