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, ∼2431🔥, 0💬
Popular Posts:
What Is session_register() in PHP? session_register() is old function that registers global variable...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
Why I am getting "LNK1104: cannot open file 'MSCOREE.lib'" error when building a C++/CLI program? Vi...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...