ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(float.fromhex('0x1p-2'), 0.25 == float.fromhex('0x1p-2'), float.fromhex('0x1.8p1'))
  1. A. 0.25 False 3.0
  2. B. 0.5 True 3.0
  3. C. 0.25 True 1.5
  4. D. 0.25 True 3.0

Correct answer: D. 0.25 True 3.0

0x1p-2 means 1 times 2 to the power -2, which is 0.25 exactly. 0x1.8p1 is 1.5 times 2, which is 3.0.

More Python Programming questions

Exams that ask this topic