ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(7 ** -1 * 7, (7 ** -1) * 7 == 1.0)
  1. A. 1 True
  2. B. 1.0 True
  3. C. 1.0 False
  4. D. 0.9999999999999999 True

Correct answer: B. 1.0 True

7 ** -1 is a float close to 1/7, and multiplying it by 7 rounds back to exactly 1.0 here. The power with a negative int exponent always gives a float.

More Python Programming questions

Exams that ask this topic