[solved]-Python Please Help Code Also Please Follow Instructions Look Code Errors Already Maybe Fi Q39041222
PYTHON. Please help with my code. Also please follow theinstructions and look at the code and errors that I already have.Maybe you can fix them…



(Math: The Complex class) Python has the complex class for performing complex number arithmetic. In this exercise, you will design and implement your Complex class. Note that the complex class in Python is named in Own lowercase, but our custom Complex class is named with C in uppercase. A complex number is a number of the form a + bi, where a and b are real numbers and i is V-1. The numbers a and b are known as the real part and the imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas (а + bi) + (с + di) — (а + с) + (b + d)i _ (с + di) %3D (а — с) + (b — d)i (а + bi) (а + bi) * (с + di) — (ас — bd) + (bс + ad)i (ас + bd)/ (c? + d?) + (bc — ad) il (с2 + d?) (а + bi)/(с + di) You can also obtain the absolute value for a complex number using the following formula a + bil= V+ Sample Run Enter the real part of the first complex number: 3.5 Enter the imaginary part of the first complex number: 6.5 Enter the real part of the second complex number: -3.5 Enter the imaginary part of the second complex number: 1 (3.56.5i) + (-3.5 + li) (0.0+7.5i) = (3.5 1i) (3.5 6.5i) (7.0+5.5i) (3.5 6.5i) li) 19.25i) (-3.5 (-18.75 (3.56.5i) / (-3.5 + li) (-0.43396226415 – 1.98113207547i) = (3.56.5i)|| 7.3824115301167 import math class Complex(object): def init(self, a, b) self.a self.b defstr_(self) return ‘(%s, %s)’ % (self.a, self.b) def_add_(self, rhs) return Complexself.a rhs.a, self.b rhs.b) Complex(0, 1) defadd(self, rhs) i – self.a rhs.a new a new b return Complex(new_a, new_b) defadd_(self, rhs) self.brhs.b a self.a b self.b rhs.a C rhs.b new_real part new_imag_part return Complex(new_real_part, new_imag_part) = a C = b d Ln: Code Analysis: Compiler Error(s) Compiler Error Messages: The compiler reported… 2 error(s) 1. SyntaxError: unexpected indent (main.py, line 20) add (self, rhs): 2. 20 def Show transcribed image text (Math: The Complex class) Python has the complex class for performing complex number arithmetic. In this exercise, you will design and implement your Complex class. Note that the complex class in Python is named in Own lowercase, but our custom Complex class is named with C in uppercase. A complex number is a number of the form a + bi, where a and b are real numbers and i is V-1. The numbers a and b are known as the real part and the imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas (а + bi) + (с + di) — (а + с) + (b + d)i _ (с + di) %3D (а — с) + (b — d)i (а + bi) (а + bi) * (с + di) — (ас — bd) + (bс + ad)i (ас + bd)/ (c? + d?) + (bc — ad) il (с2 + d?) (а + bi)/(с + di) You can also obtain the absolute value for a complex number using the following formula a + bil= V+
Sample Run Enter the real part of the first complex number: 3.5 Enter the imaginary part of the first complex number: 6.5 Enter the real part of the second complex number: -3.5 Enter the imaginary part of the second complex number: 1 (3.56.5i) + (-3.5 + li) (0.0+7.5i) = (3.5 1i) (3.5 6.5i) (7.0+5.5i) (3.5 6.5i) li) 19.25i) (-3.5 (-18.75 (3.56.5i) / (-3.5 + li) (-0.43396226415 – 1.98113207547i) = (3.56.5i)|| 7.3824115301167
import math class Complex(object): def init(self, a, b) self.a self.b defstr_(self) return ‘(%s, %s)’ % (self.a, self.b) def_add_(self, rhs) return Complexself.a rhs.a, self.b rhs.b) Complex(0, 1) defadd(self, rhs) i – self.a rhs.a new a new b return Complex(new_a, new_b) defadd_(self, rhs) self.brhs.b a self.a b self.b rhs.a C rhs.b new_real part new_imag_part return Complex(new_real_part, new_imag_part) = a C = b d Ln: Code Analysis: Compiler Error(s) Compiler Error Messages: The compiler reported… 2 error(s) 1. SyntaxError: unexpected indent (main.py, line 20) add (self, rhs): 2. 20 def
Expert Answer
Answer to PYTHON. Please help with my code. Also please follow the instructions and look at the code and errors that I already hav… . . .
OR

