What will be the output of round(2912.564, 1)?
What will be the output of round(2912.564, 1)?
Solution
In Python, round(x, n) rounds to digits after the decimal point. Here , so we keep one decimal place and look at the next digit.
The digits are 2912.5 64. The second decimal digit is 6, which is 5 or more, so the first decimal digit rises from 5 to 6. The output is 2912.6.
Option 1: this truncates (cuts off) the digits instead of rounding. Rounding looks at the next digit, which is 6, so it rounds up.
Option 3: this keeps 2 decimal places, which would be round(2912.564, 2).
Option 4: this drops the decimal part altogether. Even round(2912.564) gives 2913, not 2912.
Related questions:
2026: 23 May Shift 1
2026: 29 May Shift 2
2026: 13 May Shift 2
2025: 15 May Shift 2