Python abs() FunctionPython Functions


The abs() function returns the absolute value of the given number.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print ("abs(30): ", abs(30))
print ("abs(-40): ", abs(-40))
print ("abs(-2.9): ", abs(-2.9))
print ("abs(100.10): ", abs(100.10))

Output:

abs(30):  30
abs(-40):  40
abs(-2.9):  2.9
abs(100.10):  100.1

Syntax

abs(num)

Parameters

The method take a number as the parameter.

Return Value

It returns the absolute value of the given number.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us