sievrebo

Untitled

May 11th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. number_N1 = int(input())
  2. number_N2 = int(input())
  3. operation = input()
  4. result = 0
  5.  
  6. if operation == "+":
  7.     result = number_N1 + number_N2
  8. elif operation == "-":
  9.     result = number_N1 - number_N2
  10. elif operation == "*":
  11.     result = number_N1 * number_N2
  12. elif operation == "/" and number_N2 != 0:
  13.     result = number_N1 / number_N2
  14. elif operation == "%" and number_N2 != 0:
  15.     result = number_N1 % number_N2
  16. if (operation == "/" or operation == "%")and number_N2 == 0:
  17.     print(f"Cannot divide {number_N1} by zero")
  18. elif operation == "+" or operation == "-" or operation == '*':
  19.     if result % 2 == 0:
  20.         print(f"{number_N1} {operation} {number_N2} = {result} - even")
  21.     else:
  22.         print(f"{number_N1} {operation} {number_N2} = {result} - odd")
  23. elif operation == "/":
  24.     print(f"{number_N1} {operation} {number_N2} = {result:.2f}")
  25. else:
  26.     print(f"{number_N1} {operation} {number_N2} = {result}")
Advertisement
Add Comment
Please, Sign In to add comment