Home > Backend Development > Python Tutorial > python function - abs()

python function - abs()

高洛峰
Release: 2016-10-17 15:41:42
Original
2102 people have browsed it

Starting from today, I will update a python function every day, along with examples and points to note when using the function. I named this function topic "Daily Lecture on Python Functions". I hope everyone will support it. Haha


Starting below, today’s function is abs()


First read the official English document explanation


abs(x)

Return the absolute value of a number. The argument may be a plain or long integer or a floating point number. If the argument is a complex number, its magnitude is returned.


Detailed explanation:

returns the absolute value


The parameter can be: negative number, positive number, Floating point number or long integer


Example:

abs(-1.2) #返回 1.2
  
abs(1.2) #返回 1.2
  
abs(-11216.5) #返回 11216.5
  
abs(11216.5) #返回 11216.5
Copy after login


Note: The parameter can be a negative number or a positive number. Only the absolute value will be taken and no rounding will be done.


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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template