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, 1405🔥, 0💬
Popular Posts:
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
Where to find tutorials on Python programming language? I want to learn Python. Here is a large coll...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...
How to include additional claims in Azure AD v2.0 id_tokens? If you want to include additional claim...
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...