ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(int('0x1f', 16), int('1f', 16), int('0o17', 8))- A. 31 31 15
- B. 31 31 17
- C. 0 31 15
- D. 31 31 0
Correct answer: A. 31 31 15
int with base 16 accepts a 0x prefix and the digits 1f, which is 31. The octal string 0o17 is 1 x 8 + 7 = 15.
More Python Programming questions
- What is printed? python print(divmod(-9, 4), -9 % 4, round(-9 / 4))
- What is printed? python print(len(str(float(1016))), str(1016 1.0), len(str(1016)))
- What is printed? python print(0.1 + 0.7 == 0.8, 0.8 - 0.7, 0.3 / 0.1, int(0.3 / 0.1))
- What is printed? python print(1.0 == 1, 1.5 // 0.5, 1.5 % 0.4, 2.0 -1074 > 0, 2.0 -1075 == 0)
- What is printed? python print(float.fromhex('0x1p-2'), 0.25 == float.fromhex('0x1p-2'), float.fromhex('0x1.8p1'))
- What is printed? python print(divmod(10, 3)[::-1], divmod(-10, 3)[::-1], divmod(10, -3)[::-1])