From 4f38e0d2c8b1f8c959f16b10857946f110ea8c2b Mon Sep 17 00:00:00 2001 From: Pavel Vaks <129676672+PavelLinearB@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:53:40 +0300 Subject: [PATCH] Create cc.py --- calc/cc.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 calc/cc.py diff --git a/calc/cc.py b/calc/cc.py new file mode 100644 index 0000000..569b1c3 --- /dev/null +++ b/calc/cc.py @@ -0,0 +1,25 @@ +from operator import add, sub, mul + +def calc(): + op = input("Enter operator +-*: ") + n1 = int(input('Fist number: ')) + n2 = int(input('Second number: ')) + operators = {'+': add(n1, n2), '-': sub(n1, n2), '*': mul(n1, n2)} + if op in operators: + print('{} {} {} = {}'.format(n1, op, n2, operators[op])) + input('Press enter to return menu\n') + +def menu(): + while True: + print('(1) Calculate 2 numbers') + print('(Q) Quit') + choice = input('Enter your choice: ').lower() + if choice == '1': + calc() + elif choice == 'q': + return False + else: + print('Not a correct choice: <{}>,try again'.format(choice)) + +if __name__ == '__main__': + menu()