ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(int(3.99), int(-3.99), round(3.5), round(4.5))
- A. 3 -3 4 4
- B. 3 -4 4 5
- C. 4 -3 4 4
- D. 3 -3 4 5
Correct answer: A. 3 -3 4 4
int truncates toward zero, so 3.99 becomes 3 and -3.99 becomes -3. round sends halves to the nearest even integer, so 3.5 goes to 4 and 4.5 goes to 4.
More Python Programming questions
- What is printed? python print('ab' in ['ab', 'cd'], 'ab' in 'cdab', [] in [[]])
- What is printed? python x = [1, 2, 3] del x[::2] print(x)
- What is printed? python print(max(map(len, ['aa', 'b', 'ccc'])))
- What is printed? python print(bool(range(0)), bool(range(1)), bool({0: 0}))
- What is printed? python print(sorted([True, 0, 2, False]))
- What is printed? python print(7 // 2 2, 7 / 2 2, 2 3 2)