From fe9b61238a0a8aaad4917ccfb6ed620ac637c133 Mon Sep 17 00:00:00 2001 From: Taesung Hwang Date: Tue, 16 Aug 2022 22:53:33 -0700 Subject: [PATCH] Implement calculator division operation --- calculator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/calculator.py b/calculator.py index 93e7288..97cb855 100644 --- a/calculator.py +++ b/calculator.py @@ -10,8 +10,11 @@ def sub(x, y): def mult(x, y): pass -def div(x, y): - pass +def div(x: int, y: int) -> float: + """Divides the two numbers. Raises ValueError if the divisor is zero.""" + if y == 0: + raise ValueError("Divisor cannot be zero") + return x / y if __name__ == '__main__': if len(sys.argv) != 3: