From 2d534337e6d0292ae97d4f96f9ed7f9d42eff793 Mon Sep 17 00:00:00 2001 From: AnujWani Date: Sun, 14 Oct 2018 18:07:16 +0530 Subject: [PATCH] Issue#47 --- programs/Python/Calculator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 programs/Python/Calculator.py diff --git a/programs/Python/Calculator.py b/programs/Python/Calculator.py new file mode 100644 index 0000000..abf1f1d --- /dev/null +++ b/programs/Python/Calculator.py @@ -0,0 +1,18 @@ +num1 = float(input("Enter number a: ")) +op = input("Enter operation: ") +num2 = float(input("Enter another number b: ")) + +if op == '+': + print(num1 + num2) +elif op == '-': + print(num1 - num2) +elif op == '*' or op == 'x': + print(num1 * num2) +elif op == '/': + try: + print(num1 / num2) + except ZeroDivisionError: + print("Math error!") +else: + print("Wrong input") +