Chapter VII of three ways, the foundation of the function defined functions 03

Chapter VII of three ways, the foundation of the function defined functions 03

1, no function parameter

Defined function parameter is a function of the body receives an external transmission medium value

In parentheses is not a function of phase parameter is the no-argument function. You do not need to pass arguments when calling

If the function code logic bodies need to rely on an external incoming values, it must be defined without reference function

def func():
    print('hello nick')
    
func()  # hello nick

Second, there is a reference function

There are brackets in the function stage is to have a reference function parameters. Need to pass arguments when calling

If the function code logic relies on an external body incoming values, parameters have to be defined as a function

def sum_self(x, y):
    """求和"""
    res = x+y
    print(res)

sum_self(1,2)  # 3

Third, the empty function

When you know you need to achieve a certain function, but do not know how to use time code to achieve, you can temporarily empty write a function and then to implement other functions.

def func():
    pass

Guess you like

Origin www.cnblogs.com/demiao/p/11334879.html