From e237a7dfa2a7c6f5cd67dbda3514ebffa27fac4a Mon Sep 17 00:00:00 2001 From: faze-geek Date: Fri, 1 Mar 2024 18:00:10 +0530 Subject: [PATCH] Some changes --- python/cmath.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/cmath.py b/python/cmath.py index a246c5eb..861effac 100644 --- a/python/cmath.py +++ b/python/cmath.py @@ -68,6 +68,8 @@ 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)