# complex number in python by R4R Team

- To generate complex number, we have a 'complex' data type available in python,

Example-

3+2i is a complex number
0i is a complex number
1+0i is a complex number

How generate complex number ?
- we have a keyword 'complex' which are used to make a complex number.

like complex(3,2) will give 3+2i
complex(1,2) will give 1+2i

Syntax-

complex(real,img)

-Here complex() function takes two argument real and imaginary number.

program-

print("Enter the real number")
r=int(input())
print("Enter imaginary number")
i=int(input())

n=complex(r,i)
print("Complex number is ",n)

output-

Enter the real number
1
Enter imaginary number
2
Complex number is (1+2j)

Enter the real number
0
Enter imaginary number
1
Complex number is 1j

Enter the real number
1
Enter imaginary number
0
Complex number is (1+0j)

-In this program, we take input of two number which is real and imaginary part of the complex number. then use complex(r,i) we generate a complex number and print them.