Python function Learning

Source: Internet
Author: User

Function-Type programming

1. Simplify the code,

2, easy to call, easy to modify

3. Call parameters, shape parameters, and positional parameters. Key parameters, position parameters can only be sent after the key parameters

4. Default parameters

5. Parameter group (*ARGS) tuple parameter

6 Accept Dictionary (**kwargs) when used simultaneously must be placed at the end of the parameter


Run the program from top to bottom of the file


Local variables

A variable takes effect only in the function. External access is not available

Global variables

Variables declared at the top level of the file, local variables can be modified global variables need to use the keyword global name

Global variables cannot be modified in the function when used, otherwise it is not good to debug


Recursive functions

1. There must be a clear end condition

2. Each time a deeper level of recursion is reached, the problem size should be reduced compared to the previous recursion

3. Recursive efficiency is not high, too many recursive levels will lead to stack overflow

Python function Learning

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.