ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(10 ** -3 * 1000 == 1, 10 ** -3 * 1000)
- A. False 1.0
- B. True 1.0
- C. True 1
- D. True 0.9999999999999999
Correct answer: B. True 1.0
10 ** -3 is the float 0.001, and multiplying it by 1000 rounds to exactly 1.0. The result is a float, so it prints as 1.0 rather than 1.
More Python Programming questions
- What is printed? python print(int('12' 2) + int('3' 2), len({'x' n for n in range(4)}))
- What is printed? python print(bin(6 & -6), bin(6 | -6), bin(6 ^ -6))
- What is printed? python print(hex(28 - 1), oct(29), bin(24))
- What is printed? python print(str(0.5), str(0.25 + 0.125), 0.1 + 0.25)
- What is printed? python s = 'a,b;c' print(s.split(',;'), s.replace(';', ','), s.split(';'))
- What is printed? python print(max(range(5), key=lambda i: (i % 3, -i)))