Python program for addition and subtraction of complex numbers
Given two complex numbers z1 and z2. The task is to add and subtract the given complex numbers.
Addition of complex number: In Python, complex numbers can be added using + operator.
Input: 2+3i, 4+5i Output: Addition is : 6+8i Input: 2+3i, 1+2i Output: Addition is : 3+5i
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Addition is : (3+5j)
Subtraction of complex numbers: Complex numbers in Python can be subtracted using – operator.
Input: 2+3i, 4+5i Output: Subtraction is : -2-2i Input: 2+3i, 1+2i Output: Subtraction is : 1+1i
Subtraction is : (1+1j)