Python round() Quiz
1. What is the output of print(round(2.5))?
A. 2
B. 1
C. 2.5
D. 3
2. What is the output of print(round(4.5))?
A. 6
B. 4.5
C. 4
D. 5
3. What is the output of print(round(6.5))?
A. 7
B. 6
C. 6.5
D. 8
4. What is the output of print(round(7.5))?
A. 9
B. 7
C. 7.5
D. 8
5. What is the output of print(round(-2.5))?
A. -3
B. -2.5
C. -2
D. 2
1 comment:
What is the output of `print(round(2.5))`?
2 is the nearest even integer to 2.5.
What is the output of `print(round(4.5))`?
4 is the nearest even integer to 4.5.
What is the output of `print(round(6.5))`?
6 is the even integer among the two nearest integers, so the half-way value rounds to 6.
What is the output of `print(round(7.5))`?
8 is the even integer among the two nearest integers, so 7.5 rounds to 8.
What is the output of `print(round(-2.5))`?
-2 is the even integer among the two nearest integers, so the exact half-way value rounds to -2.
Post a Comment