Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #Returns the sum of num1 and num2
  2. def add(num1, num2):
  3. return num1 + num2
  4.  
  5.  
  6. def main():
  7. operation = input("What do you want to do (+,-,*,/):")
  8. if(operation != "+" and operation != "-" and operation != "*" and operation != "/"):
  9. #invalid operation
  10. print("You must enter a valid operation")
  11. else:
  12. var1 = int(input("Enter num1: "))
  13. var2 = int(input("Enter num2: "))
  14. if(operation == "+"):
  15. print(add(var1, var2))
  16. elif(operation == "/"):
  17. print(div(var1, var2))
  18. elif(operation == "-"):
  19. print(sub(var1, var2))
  20. else:
  21. print(mul(var1, var2))
  22.  
  23. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement