Python -- functions, python Functions

Source: Internet
Author: User

Python -- functions, python Functions

 

Function features:
1. Data Consistency
2. Reuse of code
3. Program scalability
4. After return, other commands will not be executed and return will be terminated.
5. If multiple values are defined, the values are listed in the form of a single tuples.
6. The actual parameters and format parameters must be one-to-one matched, and there must be no more or less parameters.
7. The default value is not required when the parameter is called again.
8. The parameter group must be placed after other parameters.
9. Local variables take effect only in functions. A function is the scope of a variable.
10. global variables should not be changed in the function.

 

Python function definition method:

Def test (): # Set a function name # test # annotate function print ('function programming ') # function program processing logic return 0 # define return value, if no definition is specified, None is returned.

 

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.