Python road, Day04- function module

This Section

1, the definition of the function

2, how to use the function

3. Why use function

4, functions and procedures

5, the return value of the function

 

 

1, the definition of the function

General definition of the function (Secondary / math): Modern defined function is given a set number A, wherein the element is assumed as x, a corresponding rule is applied to the elements in A f x, denoted by f (x), to give a further set the number of B, B is assumed that the elements in the equivalent relationship between y, then x and y may be f = (x) is represented by y, the function concept comprising three elements: the domain a, C and a corresponding range rule f .

 

Define (computer) programming language function: the function is a logical structure and programming of the process.

The method defined function:

>>> DEF FIB (n-):     # Write the Fibonacci n-Series up to 
...      "" " the Print the Fibonacci Series A to n-up. " "" 
... A, B = 0,. 1 
...      the while A < n- : 
...          Print (a, End = '  ' ) 
... a, B = B, a + B 
...      Print () 

"" " 
DEF: keyword defined function 
flb: function name 
(n): defined function the parameter 
"" "" "" : documentation describes 
block: 
     a, B = 0,. 1 
     the while a <n-: 
        Print (a, End = '')
         a, b = b, a+b)
     print()
"""

 

Guess you like

Origin www.cnblogs.com/xuzhichao/p/11570285.html