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, 1625🔥, 0💬
Popular Posts:
What is EPUB 2.0 Metadata "dc:identifier" Element? EPUB 2.0 Metadata "dc:identifier" is a required m...
How to Install Docker Desktop 2.5.0 on Windows 10? You can follow this tutorial to Install Docker De...
Where to find tutorials on HTML language? I want to know how to learn HTML. Here is a large collecti...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...