abs() and round()¶
Python provides abs() and round() as built-in functions for two common numeric operations: computing absolute values and rounding to a specified number of decimal places.
abs()¶
Returns the absolute value of a number, which is its distance from zero on the number line.
print(abs(-5))
Output:
5
round()¶
Rounds floating point numbers.
print(round(3.14159,2))
Output:
3.14
Rounding to the Nearest Integer¶
print(round(5.7))
Output:
6