ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(bool(0.0 or 0j), bool(0j or 1j), 0j == 0, 1j * 1j)
  1. A. True True False (-1+0j)
  2. B. False False True (1+0j)
  3. C. False True True (2+0j)
  4. D. False True True (-1+0j)

Correct answer: D. False True True (-1+0j)

0.0 and 0j are both falsy, but 1j is not. A complex zero equals the integer 0, and 1j * 1j is -1 with a zero imaginary part.

More Python Programming questions

Exams that ask this topic