This program is written in Python and it creates a complex number using two real numbers provided by the user. The program prompts the user to input two integers x and y using the input() function and stores them as integers using the int() function.
It then creates a complex number using the complex() function, which takes two arguments: the real part and the imaginary part of the complex number. The real part is represented by the variable x and the imaginary part is represented by the variable y.
The program then prints the complex number on the console using the print() function. The complex number is displayed in the form (a+bj), where a is the real part and b is the imaginary part.
The program then prints the real part of the complex number using the real attribute of the complex number object. Similarly, it prints the imaginary part of the complex number using the imag attribute of the complex number object.
Overall, this program provides a simple implementation of how to create and display complex numbers in Python using the complex() function and the real and imag attributes. It can be used to quickly create and manipulate complex numbers in Python.
x = int(input("Enter the X Number :")) y = int(input("Enter the Y Number :")) com_num = complex(x,y) print("Complex Number: ",com_num) print("Real Part : ",com_num.real) print("Imaginary Part : ",com_num.imag)
Enter the X Number :12 Enter the Y Number :16 Complex Number: (12+16j) Real Part : 12.0 Imaginary Part : 16.0
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions