Article Directory
Function basis
def fun(name,age):
message= "my name is {},I am {} years old.".format(name,age)
print(meaasge)
print(meaasge,50)
return
fun(10,20)
def is the declaration of the function;
fun is the name of the function;
the name and age in the parentheses are the parameters of the function;
and the print line is the main part of the function, and the corresponding statement can be executed;
at the end of the function, you can return the call result (Return or yield), or not to return.
Function parameters
Function return
The function does not need to return, if there is no return value, the return value of the function is None
Functions can return numbers, strings, lists, tuples, dictionaries, collections
If multiple values are returned, the returned value will be returned as a tuple
The return statement represents the end of the function execution, and the function does not perform the operation after the return statement