Python中关于复数的问题

定义一个复数类,包括实部和虚部成员变量、构造方法、以及两个复数的加法、乘法和比较大小运算符定义。

python 有现成的复数类:

c1 = 12 + 0.2j
print("c1Value: ", c1)
print("c1Type", type(c1))

c2 = 6 - 1.2j
print("c2Value: ", c2)

#对复数进行简单计算
print("c1+c2: ", c1+c2)
print("c1*c2: ", c1*c2)

运行结果:
c1Value:  (12+0.2j)
c1Type <class 'complex'>
c2Value:  (6-1.2j)
c1+c2:  (18-1j)
c1*c2:  (72.24-13.2j)