To write a Python program that reads two integers, creates a complex number using them, and then prints the complex number along with its real and imaginary parts.
- Read an integer input from the user and assign it to the variable
a(real part). - Read another integer input from the user and assign it to the variable
b(imaginary part). - Create a complex number
xusing thecomplex(a, b)function. - Print the complex number
x. - Print the real part of
xusingx.real. - Print the imaginary part of
xusingx.imag.
Add Code Here
a=int(input())
b=int(input())
x=complex(a,b)
print(x)
print(x.real)
print(x.imag)
Thus the program has been successfully executed
