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