Python Learning path: function parameters and calls

Source: Internet
Author: User
Tags print print

Return: End Function and return value

No return: Returns none

Number of return values = 1 o'clock: Returns a specific value

The return value is a number + string + list, etc.: Returns a tuple

Need return is required function full call

def test1 ():    print (' in the Test1 ') def test2 ():    print (' in the Test2 ')    return 0 #结束函数并返回0def test3 ():    Print (' In the Test3 ')    return 1, ' Hello ', [' Alex ', ' Wupeiqi '], {' Name ', ' Alex '} #结束函数并返回0x =test1 () #return返回值可以赋值给变量y =test2 () Z=test3 () print (x) print (y) print (z)

Function parameters:

def test (x, y):    print (×)    print (y) test #1传给x, 2 to y;x,y called formal parameters (positional parameter); The position of the argument and the argument one by one corresponds; Test (y=1,x=2) # Keyword invocation: independent of the parameter order Test #位置参数调用: Match parameter one by one to test (3,y=2) #既有位置参数调用又有关键字参数调用, call execute def Test (    x    , Y, z) by position parameter: print Print (y)    print (z) test (3,z=2,y=6) test (3,y=2,6) #关键字参数不能在位置参数前面

Python Learning path: function parameters and calls

Related Article

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.