

InterviewSolution
Saved Bookmarks
1. |
What is the result of round(0.5) – round(-0.5)?(a) 1.0(b) 2.0(c) 0.0(d) Value depends on Python version |
Answer» Right choice is (d) Value depends on Python version Easiest explanation - The behavior of the round() function is different in Python 2 and Python 3. In Python 2, it rounds off numbers away from 0 when the number to be rounded off is exactly halfway through. round(0.5) is 1 and round(-0.5) is -1 whereas in Python 3, it rounds off numbers towards nearest even number when the number to be rounded off is exactly halfway through. See the below output. |
|