Seventh Python Custom Function

Source: Internet
Author: User

Functions: Encapsulating functions

Grammatical structure

def function_name (Parameters ...)

Code ....

Code ....

Code ....

Attention:

1, with a colon at the tail

2, without curly braces, but with the same indentation, if not the same indentation, not as the body of the function but as the main program

3, Custom Function no return value type-------------no type of said

Invisible parameter:

Def test_a ():
print ' Hello Robin '
print ' www.baidu.com '

Test_a ()-------Call function (anywhere, unlimited calls)

Tangible parameters:

def test_b (Val1,val2):
Print Val1,----------No wrap output, wrap output without commas
Print Val2

Test_b (12,13)

Test_b (' Hello ', ' Robin ')-----call function, passing in arguments (one by one corresponds)

Note: 12,13 are arguments, val1 and val2 are formal parameters



Classification of Python custom functions:

With a return value, no return value.

of a tangible or intangible parameter

Seventh Python Custom 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.