ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. 1.0 0.0 0.0 1 1.0

/ always returns a float, while ** with int operands stays an int when the exponent is a non-negative int. -0 is just the integer 0, and 0 ** 0.0 is 1.0 because the float exponent makes the result a float.

More Python Programming questions

Exams that ask this topic