亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Basic steps for Python custom functions

Function is an organized, reusable code segment used to implement a single or related function.

Custom functions basically have the following rules and steps:

The function code block starts with the def keyword, followed by the function identifier name and parentheses ()

Any incoming parameters and independent variables must be placed between parentheses. The first line of statements between parentheses can be used to define parameters

The first line of the function can optionally use a documentation string (used to store function descriptions)

The function content starts with a colon, and Indent

return [expression] Ends the function, optionally returning a value to the caller. Return without an expression is equivalent to returning None.

Syntax example:

def functionname( parameters ):
   "函數(shù)_文檔字符串"
   function_suite
   return [expression]

Example:

def Define a function, given a function name sum

Declare two parameters num1 and num2

The first line of the function describes the function: the sum of the two numbers

The final return statement ends the function and returns the sum of the two numbers

def sum(num1,num2):
"兩數(shù)之和"
return num1+num2
# 調(diào)用函數(shù)
print(sum(5,6))

Output result:

11
Continuing Learning
||
submitReset Code