Write a program to create complex numbers and perform addition and subtraction on these numbers.
#Complex numbers representation #Create a complex no with real part and imaginary part #Complex number is denoted in the form x + iy # x and y are real numbers and i is square root of -1 (imaginary number) x = complex(2, 3) print (type(x)) #print type of variable x print (x) #print value of x y = complex(4, 2) #create another complex number print (y) z = x + y #add the two complex numbers print (z) d = x - y #difference of two complex numbers print (d) #End of program
Advertisements