Advertisement
gr03en

Untitled

Mar 1st, 2020
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. first_num = int(input())
  2. second_num = int(input())
  3. operator = input()
  4. result = 0
  5. odd_or_even = ""
  6. if operator == "+" or operator == "*" or operator == "-":
  7. if operator == "+":
  8. result = first_num + second_num
  9. elif operator == "*":
  10. result = first_num * second_num
  11. else:
  12. result = first_num - second_num
  13.  
  14. if result % 2 == 0:
  15. odd_or_even = "even"
  16. else:
  17. odd_or_even = "odd"
  18. print(f"{first_num} {operator} {second_num} = {result} - {odd_or_even}")
  19. else:
  20. if operator == "/":
  21. if second_num:
  22. result = first_num / second_num
  23. print(f"{first_num} {operator} {second_num} = {result:.2f}")
  24. else:
  25. print(f"Cannot divide {first_num} by zero ")
  26. else:
  27. if second_num:
  28. result = first_num % second_num
  29. print(f"{first_num} {operator} {second_num} = {result}")
  30. else:
  31. print(f"Cannot divide {first_num} by zero ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement