operations = {
'+': {
'func': lambda x, y: x + y,
'name': 'сложение'
},
'-': {
'func': lambda x, y: x - y,
'name': 'вычитание'
},
'*': {
'func': lambda x, y: x * y,
'name': 'умножение'
},
'/': {
'func': lambda x, y: x / y,
'name': 'деление'
},
}
args = []
operation = None
while operation not in operations.keys():
operation = input('Выберите операцию с числами: ')
for x in range(2):
while True:
try:
args.append(int(input('Введите число: ')))
break
except ValueError:
print('\nПлохое число')
print('Вы выбрали операцию %s' % operations[operation]['name'])
print('Результат операции %s: %s' % (operations[operation]['name'], operations[operation]['func'](*args)))
b3BlcmF0aW9ucyA9IHsKICAgICcrJzogewogICAgICAgICdmdW5jJzogbGFtYmRhIHgsIHk6IHggKyB5LAogICAgICAgICduYW1lJzogJ9GB0LvQvtC20LXQvdC40LUnCiAgICB9LAogICAgJy0nOiB7CiAgICAgICAgJ2Z1bmMnOiBsYW1iZGEgeCwgeTogeCAtIHksCiAgICAgICAgJ25hbWUnOiAn0LLRi9GH0LjRgtCw0L3QuNC1JwogICAgfSwKICAgICcqJzogewogICAgICAgICdmdW5jJzogbGFtYmRhIHgsIHk6IHggKiB5LAogICAgICAgICduYW1lJzogJ9GD0LzQvdC+0LbQtdC90LjQtScKICAgIH0sCiAgICAnLyc6IHsKICAgICAgICAnZnVuYyc6IGxhbWJkYSB4LCB5OiB4IC8geSwKICAgICAgICAnbmFtZSc6ICfQtNC10LvQtdC90LjQtScKICAgIH0sCn0KCgphcmdzID0gW10Kb3BlcmF0aW9uID0gTm9uZQoKd2hpbGUgb3BlcmF0aW9uIG5vdCBpbiBvcGVyYXRpb25zLmtleXMoKToKICAgIG9wZXJhdGlvbiA9IGlucHV0KCfQktGL0LHQtdGA0LjRgtC1INC+0L/QtdGA0LDRhtC40Y4g0YEg0YfQuNGB0LvQsNC80Lg6ICcpCgpmb3IgeCBpbiByYW5nZSgyKToKICAgIHdoaWxlIFRydWU6CiAgICAgICAgdHJ5OgogICAgICAgICAgICBhcmdzLmFwcGVuZChpbnQoaW5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