Learn the second of Python function notes

Source: Internet
Author: User

---restore content starts---

1, built-in function: Take absolute value function abs ()

2, built-in function: Take maximum max (), Take Min min ()

3, built-in function: Len () is the length of the acquisition sequence

4, built-in function: Divmod (x, y), return the result is x/y quotient and modulo, display y cannot equal 0, equals 0 will error

5, built-in function: Pow (A, b) two parameters, in the case of a power

In the case of POW (x, y, z) three parameters, the value of the Y power of X is represented, and then the z-modulo results are obtained.

6. Built-in function: round (x, y) indicates that the X. is a floating-point decimal number, Y is reserved for several decimals, and the final output retains several decimal rounded values

Of course, if only x is a parameter, the default is to indicate a 0-bit rounding result after the decimal point

7, built-in functions: callable (function name), Judgment function can call

8, built-in function: Isinstance (x, y), judging an object type, the result is true returns True, False return for false

9. Built-in function: CMP (x, y), if x=y, returns 0;x>y, returns 1;x<y, returns-1

10. Built-in functions: Range () and xrange ()

The difference is as follows:

11, the built-in function of the type conversion function: Type (), int (), long (), float (), complex (), str (), list (), tuple () are more familiar with

12, Hex () returns the number of 16 digits, the OCT () returns the octal number, the CHR () parameter is an integer between 0-256, the return is the current number of the Aske Magu; Ord () is the opposite of Chr (), and its parameters are Aske Magu, Returns a decimal integer that corresponds to

13. Application of String function

Str.capitalize () is the first letter of the letter to be capitalized

Str.replace (x, y), and y, and this function an optional parameter, str.replace (x, Y, z), which indicates a few changes

Str.split (x) is the division of a string, the meaning of the argument is what to divide; This function has an optional parameter Str.split (x, y), Y is a split several times

14. Python Sequence function processing function

Filter () filters the sequence, which means that a custom function can be used to filter a sequence, to process each item of the sequence into a custom filter function, and to return a result set that makes the function true

Same as the anonymous function lambda implementation of the same example

The ZIP () and map () functions,

The difference is that the map () function has a default parameter of None, and the map () function defaults to none when it encounters the following

Map () can also do the following, but zip () can not

---restore content ends---

Learn the second of Python function notes

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.