Tuesday, 2 July 2019

Add two complex numbers

#This program explains complex data types
#Add two complex numbers
c1=3.5+5.2j
c2=2.0+1.3j
c3=c1+c2
print("sum=",c3)
print(type(c3))
print(id(c3))

"""output
F:\Programs\Datatypes>python compl.py
sum= (5.5+6.5j)

F:\Programs\Datatypes>python compl.py
sum= (5.5+6.5j)
<class 'complex'>

F:\Programs\Datatypes>python compl.py
sum= (5.5+6.5j)
<class 'complex'>
11453240

F:\Programs\Datatypes>"""

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...