[Solved]-Question 4 7 Marks Complex Number Expressed Bi B Real Numbers Represents V 1 Called Real P Q37248223
Python

Question 4. (7 marks) A complex number can be expressed as a+ bi where a and b are real numbers and i represents the V-1. a is called the real part and b is called the imaginary part Complex numbers can be added by separately summing the real parts and imaginary parts. For example: Create a class representing a complex number according to the docstring specifications below. class ComplexNumber: a) [2 marks real 0, imaginary-0): def -init-(self, ”Creates a complex number with two data attributes: a real part (real) and an imaginary part (imaginary) b) 12 marks def _str_ (self): ‘(ComplexNumber) > str Output: Returns a string representing the complex number. The format of the string is ‘(rsi)’ where r is the real part and s is the imaginary part. >>>ComplexNumber (3.1,4.2) >>> print (c) (3.14.21) The parenthesis and i are part of the string. c) 13 marks] def add (self, other) ‘(ComplexNumber, ComplexNumber) -ComplexNumber Output: Returns a new ComplexNumber object resulting from adding the ComplexNumbers self and other Show transcribed image text Question 4. (7 marks) A complex number can be expressed as a+ bi where a and b are real numbers and i represents the V-1. a is called the real part and b is called the imaginary part Complex numbers can be added by separately summing the real parts and imaginary parts. For example: Create a class representing a complex number according to the docstring specifications below. class ComplexNumber: a) [2 marks real 0, imaginary-0): def -init-(self, ”Creates a complex number with two data attributes: a real part (real) and an imaginary part (imaginary) b) 12 marks def _str_ (self): ‘(ComplexNumber) > str Output: Returns a string representing the complex number. The format of the string is ‘(rsi)’ where r is the real part and s is the imaginary part. >>>ComplexNumber (3.1,4.2) >>> print (c) (3.14.21) The parenthesis and i are part of the string.
c) 13 marks] def add (self, other) ‘(ComplexNumber, ComplexNumber) -ComplexNumber Output: Returns a new ComplexNumber object resulting from adding the ComplexNumbers self and other
Expert Answer
Answer to Question 4. (7 marks) A complex number can be expressed as a+ bi where a and b are real numbers and i represents the V-1… . . .
OR

