multiplication of two complex number in python by R4R Team

- Here we perform Multiplication of two complex.

Example-

first complex is 1+2j
second complex is 2+1j
Multiplication of both number is 5j

first complex is 5+2j
second complex is -1+0j
Multiplication of both number is -5-2j


program-

print("Enter first complex number")
n1=complex(input())
print("Enter second complex number")
n2=complex(input())

print("First complex is ",n1)
print("Second complex is ",n2)
print("Multiplication of both number is ",n1*n2)


output-

Enter first complex number
2+3j
Enter second complex number
1+2j
First complex is (2+3j)
Second complex is (1+2j)
Multiplication of both number is (-4+7j)

Enter first complex number
1+2j
Enter second complex number
2+1j
First complex is (1+2j)
Second complex is (2+1j)
Multiplication of both number is 5j


-In this program, we take input of two complex number by complex(input()) and multiple both number by '*' operator and print that multiplication.
-How complex(input()) works ? actually input() function take input of string i.e. 1+2j then by complex() we doing type casting here which convert string into required complex number.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!