Define a class called complex_number
which accepts 2 parameters during initialization:
- x: int64, float64, real component of the complex numbers
- y: int64, float64, imaginary component of the complex number
The number can exist in 2 formats:
- rectangular (cartesian)
- polar
Define the follwoing operations for the class: (these methods should be compatible with int
and float
datatypes as well)
- representation
- '=='
- '+'
- '-'
- '*'
- '/'
- '+='
- '-='
- '*='
- '/='
- '-' (e.g. a = 5, then -a should return -5)
- abs()
Also, define following methods.
- to_polar()
- to_rectangular()
- argument()
- conjugate()
Include error handling
Optional: Make the package pip installable.
Note : You are not allowed to use any internal class called complex
.