python--function

Source: Internet
Author: User

syntax and writing of functions:

function Syntax:

def functionname (parameter 1, parameter 2,......): function body (the function statement you want to implement)

Return[expression] #不带表达式的return相当于返回None

Function name Command rule:

Lowercase letters, dividing between words with _

Parameter rules:

1) without parameters, the function does not need to pass any parameters when it is run. 2) can take parameters or multiple parameters, write a few parameters, call the function, it is necessary to pass the number of parameters. 3) The parameter with default value is placed in front of the parameter without default value, otherwise it will be error.

return value:

1) can not return

2) with return, you can return a null value or return a specified value.

3) The return value can be used as the calling value of the next function, or as an alternative. But if you want to print the return value, save the return value in a variable and print it out.

python--function

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.