- Creates cleaner code
- Reusable in the future
- Get rid of unnecessary messy lines of code
You can call a function in a python script and reuse it multiple times. This means that if you have the same code repeating, it makes more sense to write a function rather than repeat the code.
Parts of a function:
- Declaration with function name and arguments that are passed to the function.
- Doc String which describes the purpose of the function.
- Code that executes inside the function.
- Return statement that sends back information.
In the next slide, we explore what each of the pieces looks like!