ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('0x1f', 16), int('0x1f', 0), int(' -12 '), int('1_000'))- A. 31 31 -12 1000
- B. 0 31 -12 1000
- C. 31 31 -12 ValueError
- D. 31 31 -12 1000000
Correct answer: A. 31 31 -12 1000
int() strips surrounding whitespace, accepts a 0x prefix when the base is 16 (or 0, which auto-detects), and allows single underscores between digits since Python 3.6. The printed value of 1_000 is 1000.
More Python Programming questions
- What is printed? python print(bin(-5), format(-5, '08b'), (-5) & 0xFF, format(-5 & 0xFF, '08b'))
- What is printed? python print(divmod(-17, 5), divmod(17, -5), divmod(-17.0, 5))
- What is printed? python print(7 // -2, -7 // 2, 7.0 // -2, -7.0 % 2)
- What is printed? python print(abs(-0.0), -0.0 == 0.0, str(-0.0), str(-0.0 + 0.0))
- What is printed? python print(sum([0.1] 10) == 1.0, sum([0.1] 10), sum([0.1] 10, 0) == 1.0)
- What is printed? python print(int(3.9999999999999999), int(-3.7), round(-3.7))