From f75e366e846332d92558afba9f419a1247cdfb28 Mon Sep 17 00:00:00 2001 From: Elizabeth Woo Date: Tue, 20 May 2025 14:45:22 -0400 Subject: [PATCH 1/3] switched to if else statements --- src/pythonCalculator.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/pythonCalculator.py b/src/pythonCalculator.py index d2790f9..3c1fff1 100644 --- a/src/pythonCalculator.py +++ b/src/pythonCalculator.py @@ -8,20 +8,19 @@ class Operation(Enum): def basicCalculator(operation, num1, num2): result = 0 - - match operation: - #if operation = ADD, return the sum - case Operation.ADD: - result = num1 + num2 - case Operation.SUBTRACT: - result = num1 - num2 - case Operation.MULTIPLY: - result = num1 * num2 - case Operation.DIVIDE: - if num2 == 0: - print("Can't divide by 0") - else: - result = num1 / num2 + + #if operation = ADD, return the sum + if operation == Operation.ADD: + result = num1 + num2 + elif operation == Operation.SUBTRACT: + result = num1 - num2 + elif operation == Operation.MULTIPLY: + result = num1 * num2 + elif operation == Operation.DIVIDE: + if num2 == 0: + print("Can't divide by 0") + else: + result = num1 / num2 return result From c4a31576194ac2d28b4dccab3e92da6f90cc5cf2 Mon Sep 17 00:00:00 2001 From: Elizabeth Woo <71103650+ElizabethW00@users.noreply.github.com> Date: Tue, 20 May 2025 14:53:35 -0400 Subject: [PATCH 2/3] Update pythonCalculator.py --- src/pythonCalculator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pythonCalculator.py b/src/pythonCalculator.py index 3c1fff1..1e54734 100644 --- a/src/pythonCalculator.py +++ b/src/pythonCalculator.py @@ -11,14 +11,17 @@ def basicCalculator(operation, num1, num2): #if operation = ADD, return the sum if operation == Operation.ADD: + print("this workshop sucks") result = num1 + num2 elif operation == Operation.SUBTRACT: + print("I hate working at this company") result = num1 - num2 elif operation == Operation.MULTIPLY: + print("My boss is the worst") result = num1 * num2 elif operation == Operation.DIVIDE: if num2 == 0: - print("Can't divide by 0") + print("u suck") else: result = num1 / num2 return result From 18bdb9cc3f2b14fa6d8526591252a8b5451aed6d Mon Sep 17 00:00:00 2001 From: Elizabeth Woo Date: Tue, 20 May 2025 14:55:49 -0400 Subject: [PATCH 3/3] comments deleted --- src/pythonCalculator.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pythonCalculator.py b/src/pythonCalculator.py index 1e54734..3bf2467 100644 --- a/src/pythonCalculator.py +++ b/src/pythonCalculator.py @@ -8,20 +8,17 @@ class Operation(Enum): def basicCalculator(operation, num1, num2): result = 0 - + #if operation = ADD, return the sum if operation == Operation.ADD: - print("this workshop sucks") result = num1 + num2 elif operation == Operation.SUBTRACT: - print("I hate working at this company") result = num1 - num2 elif operation == Operation.MULTIPLY: - print("My boss is the worst") result = num1 * num2 elif operation == Operation.DIVIDE: if num2 == 0: - print("u suck") + print("Can't divide by 0") else: result = num1 / num2 return result