हिंदी

Write a program to input two complex numbers and implement multiplication of the given complex numbers.

Advertisements
Advertisements

प्रश्न

Write a program to input two complex numbers and implement multiplication of the given complex numbers.

कोड लेखन
Advertisements

उत्तर

For complex numbers (a + bi) and (c + di), multiply real and imaginary parts using (ac - bd) + (ad + bc)i.

 
real1 = int(input("Enter real part of first complex number: "))
imag1 = int(input("Enter imaginary part of first complex number: "))
real2 = int(input("Enter real part of second complex number: "))
imag2 = int(input("Enter imaginary part of second complex number: "))

real_product = real1 * real2 - imag1 * imag2
imag_product = real1 * imag2 + imag1 * real2

print("Product =", real_product, "+", imag_product, "i")
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Review of Phython - EXERCISE [पृष्ठ २७]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 1 Review of Phython
EXERCISE | Q 17. | पृष्ठ २७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×