Python Functions related notes

Source: Internet
Author: User

Define a function to use the DEF statement

def function name (argument list):#  can have no parameter    function body

The DEF function name (parameter), when the function needs to pass in parameters, gets the arguments passed into the function.

Test, define the function test, assign the user input to the S,s parameter passed in test, print I.

def Test (i):     Print  = raw_input (") test (s)

The output results are as follows:

123123

With regard to the parameters of the function, if the default parameter is set, when the function does not have an incoming parameter that is the default parameter, the incoming parameter prints the incoming parameter

def test2 (x = 1,y = 2):    print'test=', x,'and  ', Ytest2 () test2 (3,5)

The output results are as follows:

 and 2test and 5

Python Functions related notes

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.