how to use F abs in python

In Python, the abs() function is used to return the absolute value of a number. The absolute value of a number is its distance from zero on the number line, without considering the direction. In other words, it makes negative numbers positive while leaving positive numbers and zero unchanged.

abs() function in python

The abs() function returns the absolute value of the specified number. x: A number (int, float, complex) or any object that implements the _abs_() method.
The absolute value of the given number. If the argument is a complex number, the function returns its magnitude.

float_number = -4.26
print('Absolute value of float is:',
abs(float_number))

output:

Absolute value of float is: 4.26

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top