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, 1401🔥, 0💬
Popular Posts:
How to use the "Ctrl-p Ctrl-q" sequence to detach console from the TTY terminal of container's runni...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...