ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(1e3 == 10**3, int(1e3) is not None, 1e3 // 1 == 10**3, type(1e3 // 1).__name__)
- A. True True True int
- B. True True True float
- C. True False True float
- D. False True True float
Correct answer: B. True True True float
1e3 is a float with the exact value 1000.0, and floor division of floats returns a float. Comparing it with the int 1000 is True because the values are equal.
More Python Programming questions
- What is printed? python print('%x' % -255, '%o' % 8, '%e' % 0.0, '%.0e' % 12345)
- What is printed? python print(5 & 6 | 1, 5 & (6 | 1), 5 ^ 6 & 1, 1 | 2 ^ 3 & 4)
- What is printed? python print(-1 >> 1, -1 << 2, -5 >> 10, 5 >> -0 if False else 0)
- What is printed? python print(bin(-1 & 0b111), (-1) & 0xF == 15, -16 >> 2, -15 >> 2)
- What is printed? python print(''.join(sorted(set('mississippi'))), ''.join(sorted('mississippi', key=lambda c: (-'mississippi'.count(c)…
- What is printed? python print(str(1.1 1.1), str(1.21), 1.1 1.1 == 1.21, abs(1.1 1.1 - 1.21) < 1e-12)