From 15d017c18dfb445d0a29001c5dcfb694b16db72a Mon Sep 17 00:00:00 2001 From: faze-geek Date: Fri, 1 Mar 2024 22:53:26 +0530 Subject: [PATCH] Remove separate zero division case checks --- python/cmath.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/python/cmath.py b/python/cmath.py index 861effac..1d796d82 100644 --- a/python/cmath.py +++ b/python/cmath.py @@ -68,14 +68,10 @@ class complex: def __truediv__(self, other): if type(other) is complex: denominator = other.real ** 2 + other.imag ** 2 - if denominator == 0: - raise ZeroDivisionError("Division by zero in complex number division") real_part = (self.real * other.real + self.imag * other.imag) / denominator imag_part = (self.imag * other.real - self.real * other.imag) / denominator return complex(real_part, imag_part) if type(other) in (int, float): - if other == 0: - raise ZeroDivisionError("Division by zero in complex number division") return complex(self.real / other, self.imag / other) return NotImplemented