The keyword def introduces a function definition.
It must be followed by the function name and a parenthesized list of formal parameters (if any).
The statements that form the body of the function start at the next line and must be indented.
After a function has been defined, it can be called by typing the function name immediately followed by parentheses that contain the function's arguments (if any).
- https://docs.python.org/3/glossary.html#term-function
- https://docs.python.org/3/glossary.html#term-parameter
- https://docs.python.org/3/glossary.html#term-argument
- https://docs.python.org/3/tutorial/controlflow.html#defining-functions
- https://docs.python.org/3/reference/compound_stmts.html#def
- https://docs.python.org/3/reference/expressions.html#calls
- https://www.python.org/dev/peps/pep-0008/#function-names
>>> def the_truth():
... return True
...
>>> the_truth()
True
Instructions:
Define a function named say_hello() that has no parameters and prints the string "Hello World!" to the console.
Your function should not contain a return statement, only a print statement.
After you have defined the function, call it.