ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(round(2.345, 2), round(2.355, 2), round(7.5), round(8.5))
- A. 2.34 2.35 8 8
- B. 2.35 2.36 8 8
- C. 2.34 2.36 8 9
- D. 2.34 2.35 8 7
Correct answer: A. 2.34 2.35 8 8
2.345 and 2.355 are stored just below their midpoints, so they round down to 2.34 and 2.35. The integer rounding of 7.5 and 8.5 goes to the even neighbour, 8.
More Python Programming questions
- What is printed? python print(len([x for x in range(3) for y in range(x)]), [x y for x in range(3) for y in (1, 2) if x], sum(1 for i in…
- What is printed? python data = {'a': 1} print(data.get('b', 0) + 1, data.get('a') + 1, 'a' in data, 1 in data.values())
- What is printed? python print(3 in range(5), 5 in range(5), range(0, 6, 2) == range(0, 7, 2), list(range(3, 0, -1)))
- What is printed? python print(10 % 4 == 2, -10 % 4 == 2, 10 // -4, 10 / -4)
- What is printed? python s = 'abcdef' print(s[-2:], s[:-2], s[-10:], s[::-2][0])
- What is printed? python print('abc' < 'abd' and 'x' or 'y', [] or 'empty', 0 or 0.0 or 'z')