ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(~0, ~-1, -~0, ~~5, -~-5)
  1. A. -1 0 -2 5 -4
  2. B. -1 0 1 5 -4
  3. C. -1 0 1 -6 4
  4. D. -1 1 1 5 4

Correct answer: B. -1 0 1 5 -4

~x equals -x - 1, so ~0 is -1 and ~-1 is 0. -~0 is -(-1) = 1, ~~5 is 5, and -~-5 is -(4) = -4.

More Python Programming questions

Exams that ask this topic