Creating Functions

Narrated by Gerilyn, The Coding Copywriter

Functions are groups of commands we give the computer.

print("Hey, I've used a function before.")
print("How do I make my own?")

Functions help by:

  • Making code easier to read
  • Abstracting code to work with any value
  • Making code easy to reuse
  • Dividing a complex problem into simpler ones
  • Making code easier to maintain

Creating Simple Functions

Take in Data with Parameters

Returning and Capturing Values

Returning Values

Capturing Returned Values

Volume Cylinder Example

Documenting Functions

Variable Scope

Pass-by-Copy

Functions Calling Functions

Review

Made with Slides.com