ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(1_0.0_1, 0x1_F, 1_000.0e-3)
- A. 10.01 31 1000.0
- B. 1001 31 1.0
- C. 10.01 0x1F 1.0
- D. 10.01 31 1.0
Correct answer: D. 10.01 31 1.0
Underscores are allowed between digits in float, hex and exponent literals. 1_000.0e-3 is 1000 divided by 1000, which is 1.0.
More Python Programming questions
- What is printed? python print(str(1e100)[:6], len(str(1e100)), 1e100 == 10100)
- What is printed? python print(divmod(-1, 1020), divmod(1020, -1))
- What is printed? python print(int(1e20) == 1020, int(1e20 + 1) == 1020 + 1, int(1e20) - 1020)
- What is printed? python print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])
- What is printed? python s = 'x' t = s s = s + 'y' print(t, s, t is s)