function (Def)
function is to give a program a name, use the name to execute a program, repeated use.
Keyword ' def ' to define, identifier (parameter)
Examples of function use:
1.
Def boy ():
Print ("Hi,world")
The above function is relatively simple, run this function, just print out the Hi,world
2.
Def boy (A, b):
C=a+b
Return C
Above this function, after running, if given two values, that is, the two values are added, and the return value
3.
Def boy (Str,times):
C=str * Times
Return C
Above this function, given a string, and a number, that is, returning the corresponding number
4.
def boy (str, times= 1):
C=str * Times
Return C
Above this function, there is a default value of 1, if there is no value to the function, he defaults to output 1 times
5.
Def boy (a,b=2,c=9)
Print (A,B,C)
Boy (111,21)
Boy (54,c=8)
Boy (k)
Run the above function to define multiple default values
Python function (def)