Motivation

Introduction to functions

Motivation

🙋 Need help? Ask an expert now!

Motivations

  • 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:

  1. Declaration with function name and arguments that are passed to the function.
  2. Doc String which describes the purpose of the function.
  3. Code that executes inside the function.
  4. Return statement that sends back information.

In the next slide, we explore what each of the pieces looks like!

Edit Me on GitHub!