Python 3.5.2 documents
http://docs.python.jp/3/tutorial/controlflow.html#defining-functions
4.6. Define a function ...
>>> def fib(n): # write Fibonacci series up to n
... """Print a Fibonacci series up to n."""
... a, b = 0, 1
... while a < n:
... print(a, end=' ')
... a, b = b, a+b
... print()
...
>>> # Now call the function we just defined:
... fib(2000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
The first line of the statement in the body of the function can be a string literal. In that case, this string is called the function's documentation string, or docstring. (For more information on docstrings, see Documentation Strings.)
Recommended Posts