Python function Learning points

Source: Internet
Author: User
Tags function definition

First, the function definition:

A function is to encapsulate a set of statements by a name (function name), and to execute the function, simply call the name of its functions. "Methods in the same Java"

Second, define the function

The definition function uses the DEF keyword, followed by the function name, and the function name cannot be duplicated

Three, the function to pass the parameter attention point

1. * * parameters, pass the dictionary "non-mandatory"

2. *args can be used to customize the parameters, or do not pass the parameter

2. * * parameters, you can also pass the key parameter "non-required"

3. Note the order of the parameters: positional, default, variable, keyword "include dictionary"

Third, function return value attention point

1. Return type

A return value can return 0 or 1 or more

Directly returns only Ture or False is a Boolean type

Generally returns multiple is generally a tuple, which can be learned by printing the type

2. The positioning of the return value can be obtained by subscript, as

Python function Learning points

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.