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, ∼2227🔥, 0💬
Popular Posts:
How to use 'choose ... when ..." policy statements to control execution flows? If you want to contro...
How To Protect Special Characters in Query String in PHP? If you want to include special characters ...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
What properties and functions are supported on http.client.HTTPResponse objects? If you get an http....
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...