python--Basic Methods (2)

Source: Internet
Author: User

Python has built in a lot of useful functions that we can call directly.

To invoke a function, you need to know the name and parameters of the function, and you can view the document directly from the official Python website.

A common approach:

Absolute method ABS (-100), obtained 100;

Max value Method Max (1,2,23,-20,100), get 100;

Data type conversion method int (' 221 '), get digital 221;int (12.344) Get 12;bool (1) Get True,bool () get false

>> int ('123')123>>> int (12.34)12>>> float ( ' 12.34 ' )12.34>>> str (1.23)'1.23'>>> str (+)  '+'>>> bool (1) True

The function name is actually a reference to a function object, it is possible to assign a function name to a variable, which is equivalent to giving the function an "Alias

# variable a points to the ABS function # so you can also call the ABS function by a 1

Use the Python built-in hex() function to convert an integer to a hexadecimal-represented string

Print (Hex (n1+1))

python--Basic Methods (2)

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.