0

I am new to python so my question may sound silly. Trying to print some complex numbers.

t1 = 5j
t2 = -5j
print(t1)
print(t2)

This prints:

5j
(-0-5j)

Can someone please explain what is the rule/logic behind this formation?

Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
  • Does this answer your question? [Format of complex number in Python](https://stackoverflow.com/questions/13387782/format-of-complex-number-in-python) – JeffUK Dec 06 '21 at 03:55

1 Answers1

1

The print function is doing its best to print a mathematical equation to represent the number, which is then surrounded by parenthesis. In the second case, the notation is the real number added to the imaginary component. Further reading here.

Juicestus
  • 442
  • 1
  • 7
  • 14