From 5ded500aba56b0f3f0417e07e4c354414e9977e5 Mon Sep 17 00:00:00 2001 From: Utkarsh Mall Date: Thu, 1 Oct 2020 18:04:28 +0530 Subject: [PATCH 1/2] Update app.py Added a function which is called again and again to make calculations fast, and user can stop it by pressing 0. --- app.py | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) 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 From 8183d094033aa6968e88a65f93cc6f4c8cfd21ca Mon Sep 17 00:00:00 2001 From: Utkarsh Mall <69422566+Assertor1@users.noreply.github.com> Date: Thu, 1 Oct 2020 18:06:33 +0530 Subject: [PATCH 2/2] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md 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