Python function learning, python Function

Source: Internet
Author: User

Python function learning, python Function
Functional Programming

1. Simplified code,

2. Convenient calling and convenient Modification

3. Call parameters, shape parameters, and location parameters. Key parameter. The location parameter can only be sent after the key parameter.

4. Default Parameters

5. parameter group (* args) tuples

6. When using the dictionary (** kwargs) at the same time, it must be placed at the end of the parameter.


Running the program from top to bottom of the file


Local variable

A variable takes effect only in the function. External access failed

Global Variables

For variables declared at the top level of the file, you can use the keyword global name to modify global variables.

We do not recommend that you use global when using it. You cannot modify global variables in the function. Otherwise, debugging is not good.


Recursive functions

1. There must be a clear termination condition

2. Each time you enter a deeper layer of recursion, the problem scale should be reduced compared to the previous recursion.

3. Too many recursive layers may cause stack overflow.

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.