What is the python abs function? What is the use of ABS functions?

Source: Internet
Author: User
Tags abs
In this article, we'll look at the abs function in Python, and in this article we'll explain what the ABS function means and where it's generally used, as well as its role and meaning.


The ABS () function returns the absolute value of the number.


The following is the syntax for the ABS () method:

ABS (x)


X--Numeric expression.

return value

The function returns the absolute value of the X (number).


Examples of using the ABS () method are shown below:

#!/usr/bin/pythonprint "ABS ( -45):", ABS ( -45) print "ABS (100.12):", ABS (100.12) print "ABS (119L):", ABS (119L)

When the above instance is run, the output is:

ABS ( -45):  45abs (100.12):  100.12abs (119L):  119
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.