yordan_yordanov

код

Jul 19th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. N1 = int(input())
  2. N2 = int(input())
  3. operator = input()
  4.  
  5. result = 0
  6. state = ""
  7.  
  8. if operator == '+':
  9. result = N1 + N2
  10. if result % 2 == 0:
  11. state = 'even'
  12. else:
  13. state = 'odd'
  14. print(f"{N1} {operator} {N2} = {result} - {state}")
  15. elif operator == '-':
  16. result = N1 - N2
  17. if result % 2 == 0:
  18. state = 'even'
  19. else:
  20. state = 'odd'
  21. print(f"{N1} {operator} {N2} = {result} - {state}")
  22.  
  23. elif operator == '*':
  24. result = N1 * N2
  25. if result % 2 == 0:
  26. state = 'even'
  27. else:
  28. state = 'odd'
  29. print(f"{N1} {operator} {N2} = {result} - {state}")
  30.  
  31. elif operator == '/':
  32. if N2 == 0:
  33. print(f"Cannot divide {N1} by zero")
  34.  
  35. else:
  36. result = N1 / N2
  37. print(f"{N1} / {N2} = {result:.2f}")
  38.  
  39. elif operator == '%':
  40. if N2 == 0:
  41. print(f"Cannot divide {N1} by zero")
  42. else:
  43. result = N1 % N2
  44. print(f"{N1} % {N2} = {result}")
Advertisement
Add Comment
Please, Sign In to add comment