Ddimov90

operation_between_numbers_06_02

Sep 30th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | Source Code | 0 0
  1. num_one = int(input())
  2. num_two = int(input())
  3. operator = input()
  4.  
  5. total = 0
  6.  
  7. if operator == "+" or operator == "*" or operator == "-":
  8.     even_or_odd = ""
  9.     if operator == "+":
  10.         total = num_one + num_two
  11.     elif operator == "-":
  12.         total = num_one - num_two
  13.     else:
  14.         total = num_one * num_two
  15.  
  16.     if total % 2 == 0:
  17.         even_or_odd = "even"
  18.     else:
  19.         even_or_odd = "odd"
  20.  
  21.     print(f"{num_one} {operator} {num_two} = {total} - {even_or_odd}")
  22.  
  23. elif operator == "/":
  24.     if num_two != 0:
  25.         total = num_one / num_two
  26.         print(f"{num_one} / {num_two} = {total:.2f}")
  27.     else:
  28.         print(f"Cannot divide {num_one} by zero")
  29.  
  30. else:
  31.     if num_two != 0:
  32.         total = num_one % num_two
  33.         print(f"{num_one} % {num_two} = {total}")
  34.     else:
  35.         print(f"Cannot divide {num_one} by zero")
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment