3) Functions

Functions are extremely helpful for creating code shortcuts that are often repeated throughout a program.

The def command tells Python that the following code will contain a function. Below, say_hi is the function; the function can be named anything as longs it contains no spaces. Then, write the code you wish to run when the function is called upon:

Functions can utilize outside information that can be used within the function. You can accomplish this by declaring the variables in the function.

The return command will provide the result of the code. To run the function, you need to provide outside information.

Leave a Reply