function:
The concept of functions: is a piece of code; section of the operation flow.
Advantages: less code, simple. Maintenance is easy - make changes in the definition of the function
Defined functions: 1 - def function name ():
Function content
2 - is defined function code does not perform the function of the content of
3 - Case: def func ():
print('step1')
4 - type(func) ------- <class 'function'>
Calling the function: 1 - func ()
2 - when the call was to perform
3 - defined function to be called in front of certain functions
Parameters: 1 - parameter: ① in the function definition parameters def func (a, b): a, b is the parameter
② In pycharm parameter is not used if a gray, black is used
③def func (a, b): General Parameters As long as a required parameter name ---
2 - argument: ① when the actual function call parameters passed func (1, 2) 1, 2 are arguments
② when the function call can not use the following wording: func (a = 1,2)
Returns: 1 - When the function call is completed, there will be a return value
2 - which has a return value of the function
3 - Return Value Type: ①None ----- No return
② any type
③ return type of the function - the latter depending on the type of return
④ after the return statement will not be executed - upon execution of the function to return the function call has been completed
+ Local variables global variables: 1 - Global Variables - which further .py file, a variable Once defined, all codes can be used later
2 - Local variables - inside function.
Type conversion - Built-in functions: 1 - int () -------- converted content must be converted int purely digital
2 - str () -------- into a string
3 - float () ------ converted to floating point
Precautions:
a = 3.14 ---- float type
print (int (a)) ----- ----- rounding fractional part is discarded. 3
a = '3.14' ------- str type
print (int (a)) -------- given, the value is not decimal content
input () ------------ return value is str