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'))- A. 0.25 False 3.0
- B. 0.5 True 3.0
- C. 0.25 True 1.5
- 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
- What is printed? python print(divmod(10, 3)[::-1], divmod(-10, 3)[::-1], divmod(10, -3)[::-1])
- What is printed? python print(-5 % 3 == 1, 5 % -3 == -1, -5 // -3, 5 // -3)
- What is printed? python s = 'a-bc d' print(s.replace('-', ' ').replace('', ' ').split(), s.translate({45: None}))
- What is printed? python print('abc'.index('c') + 'abc'.rindex('a'), 'aXbXc'.rsplit('X', 1), 'a b'.title())
- What is printed? python import string print(string.asciilowercase.index('z'), string.digits[::-1][:3], string.asciiuppercase[25] +…
- What is printed? python print(int('1' 30) % 97, pow(10, 30, 97), (1030 - 1) // 9 % 97)