ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(0 ** 0, 0.0 ** 0, (-8) ** 0, (-2) ** 3, -2 ** 3)
  1. A. 1 1.0 1 -8 -8
  2. B. 1 1.0 0 -8 -8
  3. C. 0 1.0 1 -8 -8
  4. D. 1 1 1 -8 -8

Correct answer: A. 1 1.0 1 -8 -8

Any number to the power 0 is 1, and the float case stays a float: 0.0 ** 0 is 1.0. -2 ** 3 parses as -(2 ** 3), which is -8, the same as (-2) ** 3 here.

More Python Programming questions

Exams that ask this topic