What does python abs mean? What is the use of abs function?

乌拉乌拉~
Release: 2019-07-10 13:48:48
Original
40910 people have browsed it

In today's article, we will learn about theabs functionin python. In this article, we will explain what theabs function means, and how this function is generally used. Where, and its role and significance.

What does python abs mean? What is the use of abs function?

Description

abs() function returns the absolute value of a number.

Syntax

The following is the syntax of the abs() method:

abs( x )
Copy after login

Parameters

x – Numeric expression.

Return value

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

Example

The following shows an example of using the abs() method:

# !/usr/bin/python print "abs(-45) : ", abs(-45) print "abs(100.12) : ", abs(100.12) print "abs(119L) : ", abs(119L)
Copy after login

The output result after running the above example is:

abs(-45) : 45 abs(100.12) : 100.12 abs(119L) : 119
Copy after login

The above is all about the abs function in python in this article. I hope what I said and the examples I gave can be helpful to you.

For more related knowledge, please visit thePython tutorialcolumn on the php Chinese website.

The above is the detailed content of What does python abs mean? What is the use of abs function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!