forked from FirmanKurniawan/Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif-complex.py
More file actions
33 lines (25 loc) · 723 Bytes
/
Copy pathif-complex.py
File metadata and controls
33 lines (25 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Code to illustrate complex number
# covert real number to complex
num = complex(5,3)
print(num)
# covert real number to complex
num = complex(5,-4)
print(num)
# Default if no parameter is passed to complex method
num = complex()
print(num)
# In case if you pass only real number, defaults imaginary to 0
num = complex(5)
print(num)
# In case if you pass only real number, defaults imaginary to 0
num = complex(-2)
print(num)
# In case if you pass only float number, defaults imaginary to 0
num = complex(5.6,4)
print(num)
# if string is passed, it will be interpreted as complex number
num = complex('8')
print(num)
# if string is passed, it will be interpreted as complex number
num = complex('1+2j')
print(num)