Решение на "Operations Between Numbers"
Моето решение с по-малко писане на код.
import operator
n_1 = int(input())
n_2 = int(input())
symbol = input()
allowed_operators = {"+": operator.add, "-": operator.sub, "*": operator.mul}
if symbol == '+' or symbol == '-' or symbol == '*':
result = allowed_operators[symbol](n_1, n_2)
if result % 2 == 0:
even_odd = 'even'
else:
even_odd = 'odd'
print(f'{n_1} {symbol} {n_2} = {result} - {even_odd}')
elif symbol == '/' and not (n_2 == 0):
result = n_1 / n_2
print(f'{n_1} / {n_2} = {result:.2f}')
elif symbol == '%' and not (n_2 == 0):
result = n_1 % n_2
print(f'{n_1} % {n_2} = {result}')
else:
print(f'Cannot divide {n_1} by zero')