What Dian a return value of
the result function of the internal logic code is obtained through a series of.
def func():
name = 'nash'
return name
name = func()
print(name)
nash
Two Dian Why should there be a return value
processing function to get the desired results in the program for further processing, we need to function must have a return value.
- return function is a sign of the end, there can be multiple return within a function, to return as long as the execution, the function will be executed.
- return return value can return any data type
- The number of non-return return value limitations, which can return multiple values separated by commas
- 0: return None
- 1: The return value is the value itself
A plurality of: The return value is a tuple
`` `pythonWhy should there be a return value
def max_self(salary_x, salary_y):
if salary_x > salary_y:
return salary_x
else:
return salary_y
max_salary = max_self(20000, 30000)
print(max_salary*12)
`360000`
python
A plurality of function return value
def func():
name = 'nash'
age = 18
hobby_list = ['read', 'run']
return name, age, hobby_list
name, age, hobby_list = func()
print(f"name,age,hobby_list: {name,age,hobby_list}")
``
name,age,hobby_list: ('nash', 18, ['read', 'run'])
`