Python built-in functions (1) -- abs, python built-in functions abs

Source: Internet
Author: User

Python built-in functions (1) -- abs, python built-in functions abs

English document:

Abs (X)

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

Note:

1. Return the absolute value of a number. The parameter can be an integer, floating point, or plural number.

2. If the parameter is a plural number, this method returns the absolute value of this plural number (the square root of the product of this plural number and Its Bounded plural number)

Example:

>>> Help (abs) Help on built-in function abs in module builtins: abs (x,/) Return the absolute value of the argument. >>> abs (2) # positive integer 2 >>> abs (-2) # negative integer 2 >>> abs (0) #00 >>> abs (2.3) # Positive floating point number 2.3 >>> abs (-2.3) # negative floating point number 2.3 >>>> c1 = complex () >>> c1 # plural (1 + 1j) >>> abs (c1) # absolute value of the plural number 1.4142135623730951 >>>> c2 = complex (-1,-1) >>>> c2 # plural (-1-1j) >>> abs (c2) # the absolute value of the plural is 1.4142135623730951 >>>

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.