ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(-(2 ** 3) ** 2, (-2) ** 3 ** 2, -2 ** -1, 0)
  1. A. -64 512 -0.6 0
  2. B. 65 -512 -0.5 0
  3. C. -64 -512 -0.5 1
  4. D. -64 -512 -0.5 0

Correct answer: D. -64 -512 -0.5 0

** binds tighter than unary minus on its left, so -(2 ** 3) ** 2 is -64. The exponent 3 ** 2 is 9, so (-2) ** 9 is -512, and -2 ** -1 is -(2 ** -1) = -0.5.

More Python Programming questions

Exams that ask this topic