Tools, FAQ, Tutorials:
'def' - Function Definition Statements
How to use the "def" statement to define a new function in Python?
✍: FYIcenter.com
You can use the "def" statement to define a new function in Python
with the following syntax:
def function_name(paramenter_list):
statement_block
Here is a good example of "def" statement defining a function to generate Fibonacci series:
>>> def fib(n): # write Fibonacci series up to n ... """Print a Fibonacci series up to n.""" ... a, b = 0, 1 ... while a < n: ... print(str(a)+", ", end='') ... a, b = b, a+b ... else: ... print() ... >>> fib(2000) 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
⇒ 'return' Statement in Function Statement Block
2018-02-28, ∼2414🔥, 0💬
Popular Posts:
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
How to install "C++/CLI Support" component in Visual Studio? I need to build my Visual Studio C++/CL...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...
How to validate the id_token signature received from Azure AD v2.0 authentication response? You can ...