I’m beginning to learn about Python and am starting to understand the importance between integers and floats and how they are different objects. For example, the integer 1
is not the same as the float 1.0
. I am confused because Python does not do this for complex numbers.
If I define a complex number as z1 = 1.0 + 2.0j
and print it, the output will be (1+2j)
. I would have assumed that the output will be (1.0+2.0j)
, but this is not the case. Furthermore, when I define another complex number z2 = 1 + 2j
and test whether these two variables reference the same object, they do. So what is going on here?
Eigenfield is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
7