From 7d46ab281de7f586d271c61da9edc2a6ccc4b31d Mon Sep 17 00:00:00 2001 From: preetam kumar Date: Sat, 18 Oct 2025 23:42:57 +0530 Subject: [PATCH 1/2] Added simple calculator script --- scripts/simple_calculator.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/simple_calculator.py diff --git a/scripts/simple_calculator.py b/scripts/simple_calculator.py new file mode 100644 index 000000000000..5e02171a9b5c --- /dev/null +++ b/scripts/simple_calculator.py @@ -0,0 +1,33 @@ +def add(a, b): + return a + b + +def subtract(a, b): + return a - b + +def multiply(a, b): + return a * b + +def divide(a, b): + if b == 0: + return "Error: Division by zero" + return a / b + +if __name__ == "__main__": + print("Simple Calculator") + x = float(input("Enter first number: ")) + y = float(input("Enter second number: ")) + op = input("Enter operation (+, -, *, /): ") + + if op == '+': + print("Result:", add(x, y)) + elif op == '-': + print("Result:", subtract(x, y)) + elif op == '*': + print("Result:", multiply(x, y)) + elif op == '/': + print("Result:", divide(x, y)) + else: + print("Invalid operation!") + + + From 1bc5fddb33bf720f3710413ffbd376f8134d1db5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:17:25 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/simple_calculator.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/simple_calculator.py b/scripts/simple_calculator.py index 5e02171a9b5c..76d3753e024b 100644 --- a/scripts/simple_calculator.py +++ b/scripts/simple_calculator.py @@ -1,33 +1,34 @@ def add(a, b): return a + b + def subtract(a, b): return a - b + def multiply(a, b): return a * b + def divide(a, b): if b == 0: return "Error: Division by zero" return a / b + if __name__ == "__main__": print("Simple Calculator") x = float(input("Enter first number: ")) y = float(input("Enter second number: ")) op = input("Enter operation (+, -, *, /): ") - if op == '+': + if op == "+": print("Result:", add(x, y)) - elif op == '-': + elif op == "-": print("Result:", subtract(x, y)) - elif op == '*': + elif op == "*": print("Result:", multiply(x, y)) - elif op == '/': + elif op == "/": print("Result:", divide(x, y)) else: print("Invalid operation!") - - -