diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b02ddc --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Better-Simple-Python-Calculator +A more functional simple calculator created in Python diff --git a/app.py b/app.py index 4967d59..231ba72 100644 --- a/app.py +++ b/app.py @@ -1,15 +1,27 @@ +def calc(): + ''' This is a functiion which when called, perform calculation tasks which user wants ''' + + num1 = float(input("Enter first number: ")) + op = input("Enter operator: ") + num2 = float(input("Enter second number: ")) + + if op == "+" : + print(num1 + num2) + elif op == "-" : + print(num1 - num2) + elif op == "/" : + print(num1 / num2) + elif op == "*" : + print(num1 * num2) + elif op == "**" : + print(num1 ** num2) + else: + print("Invalid operator") + +while True: + i = int(input("Press 1 to Continue, otherwise press 0\n")) + if i == 1: + calc() + else: + break -num1 = float(input("Enter first number: ")) -op = input("Enter operator: ") -num2 = float(input("Enter second number: ")) - -if op == "+": - print(num1 + num2) -elif op == "-": - print(num1 - num2) -elif op == "/": - print(num1 / num2) -elif op == "*": - print(num1 * num2) -else: - print("Invalid operator") \ No newline at end of file