Python standard library: built-in functions abs (x), pythonabs

Source: Internet
Author: User

Python standard library: built-in functions abs (x), pythonabs

Returns the absolute value of a number. The parameter can be an integer or floating point number. If the parameter is a plural value, the modulo of the plural value is returned. Therefore, the note of abs () function is that the complex numbers are calculated differently.

Example:

# Positive integer print ('abs (1): ', abs (1) # negative integer print ('abs (-1):', abs (-1 )) # print ('abs (-10.5): ', abs (-10.5) # print ('abs (3 + 4j ):', abs (3 + 4j ))

The output result is as follows:

Abs (1): 1

Abs (-1): 1

Abs (-1, 10.5): 10.5

Abs (3 + 4j): 5.0

In this example, 1,-1 is an integer,-10.5 is a floating point, and 3 + 4j is a plural number.


Cai junsheng QQ: 9073204 Shenzhen


How to view built-in functions in python

Import sys
Print dir (sys. modules ['_ builtin _'])

Who will give an example of several python built-in functions?

All built-in functions of python

Abs () divmod () input () open () staticmethod ()
All () enumerate () int () ord () str ()
Any () eval () isinstance () pow () sum ()
Basestring () execfile () issubclass () print () super ()
Bin () file () iter () property () tuple ()
Bool () filter () len () range () type ()
Bytearray () float () list () raw_input () unichr ()
Callable () format () locals () reduce () unicode ()
Chr () frozenset () long () reload () vars ()
Classmethod () getattr () map () repr () xrange ()
Cmp () globals () max () reversed () zip ()
Compile () hasattr () memoryview () round () _ import __()
Complex () hash () min () set () apply ()
Delattr () help () next () setattr () buffer ()
Dict () hex () object () slice () coerce ()
Dir () id () oct () sorted () intern ()

I have read it all over again. What kind of usage do you want to know?

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.