# 1. What is the result of the execution of the following code:

+25 votes
asked May 12, 2023
closed Jul 5, 2023
```2.Why does round(5 / 2) return 2 instead of 3?  (BRAIN)
>>> round(7 / 2)
>>> round(3 / 2)
>>> round(5 / 2)```
closed with the note: answered

## 10 Answers

+3 votes
answered May 12, 2023 by (410 points)
reshown May 13, 2023 by ANG YU NING Moe

Best answer

Answer 1: 4, 2, 2

Answer 2:The issue here is that Python’s round method implements banker’s rounding, where all half values will be rounded to the closest even number.

commented May 13, 2023 by (410 points)
THIS IS THE ANSWER IF YOU DON'T KNOW :)
0 votes
answered May 16, 2023 by (140 points)
the answer is 2.5 so if its returning an integer, it will disregard everything after the decimal point
0 votes
answered May 16, 2023 by (300 points)

the round() function rounds the quotients of 7/2 and 3/2 to the nearest integer, which is 3 and 1, respectively. However, the quotient of 5/2 is rounded to 2. This is because the quotient 2.5 is closer to 2 than it is to 3.

0 votes
answered May 24, 2023 by (150 points)
answer 4,3,3
commented May 30, 2023 by (410 points)
thx for answering :>
+1 vote
answered May 25, 2023 by (160 points)
Answers: 4 2 2

the round() function performs rounding based on certain rules. In the case of half-values (e.g., 2.5), it rounds to the nearest even number. This behavior is known as "round half to even" or "rounding to nearest, ties to even."
0 votes
answered May 26, 2023 by (140 points)
because when you divide integers the outputted value is the floor (rounded down answer)
0 votes
answered May 26, 2023 by (140 points)
because integer / integer is always be a integer

like 5/2 is integer /integer then answer is integer it remove the number after the point and showing only who's number are before point
0 votes
answered May 29, 2023 by (180 points)
The result of the execution of the following code is:

2
3
2

The round() function rounds a number to the nearest integer. In the first two cases, the result is the nearest integer to the quotient of the two numbers. In the third case, the quotient, 2.5, is halfway between 2 and 3. The round() function rounds halfway cases to the even number, so the result is 2.

The round() function uses a rounding algorithm called banker's rounding. Banker's rounding is a rounding algorithm that rounds halfway cases to the even number. This algorithm is often used in financial applications because it is considered to be more fair than other rounding algorithms.
0 votes
answered Jun 23, 2023 by (140 points)

rounding option rounds to the next higer integer value if the number of digits for precision is zero. hence 5/2 is only 3.  not 2

4

2

3

0 votes
answered Jun 28, 2023 by (140 points)
When we divide 5 with 2 we can get the answer which is in the decimal format that is 2.5.  So if the data type is int for the variable it prints 2 and removes decimal value 0.5.  Hence, the answer is 2 instead of 3
commented Jul 5, 2023 by (100 points)
moved Jul 5, 2023 by meenu parmar
3

1

2

it doesn't consider decimal value

as 7/2 gives 3 as quotient and 1 as a remainder.

so, output will be 3..

for 5/2 =2   and  3/2=1