A python module that allows the use of complex numbers and their properties in the program
Keep the complexNo.py file in the same directory as the program which needs the implemetation of complex numbers. Now write the following code :
from complexNo import ComplexNo
Now you are ready to use complex numbers in your program
- c1=ComplexNo(a,b) : Creates a complex number c1 with a as the real part and b as the imaginary part
- c3=c1+c2 : Adds two complex numbers c1 and c2 and stores it in c3, a complex number
- c3=c1-c2 : Subracts a complex number c2 from c1 and stores it in c3, a complex number
- c3=c1*c2 : Multiplies two complex numbers c1 and c2 and stores it in c3, a complex number
- c3=c1/c2 : Divides two complex numbers c1 and c2 and stores it in c3, a complex number
- c3=c1//c2 : Divides two complex numbers c1 and c2 , floors it and stores it in c3, a complex number
- c3=c1.arg() : Returns the argument of a complex number c1 and stores it in c3, a float value
- c3=c1.mod() : Returns the modulus of a complex number c1 and stores it in c3, a float value
- c3=c1.conj() : Returns the conjugate of a complex number c1 and stores it in c3, a complex number
- c3=c1.sqrt() : Returns the square root of a complex number c1 and stores it in c3, a complex number
- c3=c1**n : Returns the exponential of a complex number c1 to the power n and stores it in c3, a complex number
- print(c1) : Displays the a complex number c1