Python learning notes --- form parameters (parameter) and actual parameters (argument), pythonargument

Source: Internet
Author: User

Python learning notes --- form parameters (parameter) and actual parameters (argument), pythonargument

Def mydemo (name ):
'Name in the function definition process is called a form parameter'
# Because it is only a form that occupies a parameter location
Print ('passed in '+ name +' is called a real parameter because it is a specific parameter value! ')
Mydemo ('john ')
# John passed in the function call process is called a real parameter because it is a specific parameter value!
Mydemo (name = 'john ')
# When a function is called, if too many parameters are passed, the location of the parameters corresponding to the parameters is unclear. Therefore, when calling a function, you can assign values to the parameters directly.

The keyword parameter is the built-in parameter of the function.

The default parameter is to assign an initial value to the form parameter.

A collection parameter is a * parameter added before the parameter, which can also be called a variable parameter.
Def test (* arg)
Print ('parameter length: ', len (arg ))
Print ('second parameter: ', arg [1])
Test (, 'abc', 'de', 'China', 7)

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.