ProgrammingModerateProduct-company MCQ pattern
What is printed?
What is printed?
print(round(2.5), round(3.5), round(-0.5))
- A. 2 3 0
- B. 3 4 0
- C. 2 4 0
- D. 3 4 -1
Correct answer: C. 2 4 0
Python 3's round() uses banker's rounding: an exact .5 goes to the nearest EVEN integer. So 2.5 → 2, 3.5 → 4 and -0.5 → 0. 'Always round half up' gives the trap answer 3 4.
More Python Programming questions
- What is printed? python class A: count = 0 a1, a2 = A(), A() a1.count += 1 print(A.count, a1.count, a2.count)
- What is printed? python a = [[0] 3] 3 a[0][0] = 1 print(a)
- What is printed? python def f(x, lst=[]): lst.append(x) return lst f(1) f(2) print(f(3))
- What is printed? python x = 10 def f(): x += 1 return x try: f() except Exception as e: print(type(e).name)
- What is printed? python g = (i i for i in range(4)) print(sum(g), sum(g))
- What is printed? python print({1, 2, 3} ^ {2, 3, 4}, {1, 2} <= {1, 2, 3})