ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(int(3.7 * 10), int(0.7 * 10), 3.7 * 10 == 37, 0.7 * 10 == 7)
- A. 37 7 True False
- B. 36 7 True True
- C. 37 7 True True
- D. 37 6 True True
Correct answer: C. 37 7 True True
3.7 * 10 rounds to exactly 37.0, and 0.7 * 10 rounds to 7.0 even though 0.7 is stored slightly below its value. Both int() conversions truncate those whole numbers unchanged.
More Python Programming questions
- What is printed? python print(sorted([True, 2, 1.5, False, -1]))
- What is printed? python print(1 if [] == [] is True else 0, [] is [], () is ())
- What is printed? python print(len(str(float(10300))), str(float(1022))[:4], float(1022) == 1022)
- What is printed? python print(10 // 3, 10 % 3, divmod(10, 3), (10 // 3) 3 + 10 % 3)
- What is printed? python print([1, 2, 3].index(2), 'abc'.index('bc'), (1, 2).index(2), [1, 2, 3].count(4))
- What is printed? python print(float('-0') == 0, str(float('-0')), str(0 -1.0), 0.0 -1)