10. What’s Your Function

  1. 10.1. Introduction
    1. 10.1.1. What is a Function?
    2. 10.1.2. Function Control Flow
    3. 10.1.3. Check Your Understanding
  2. 10.2. Calling Functions
    1. 10.2.1. Making a Function Run
      1. 10.2.1.1. Try It!
    2. 10.2.2. Why Use Functions?
  3. 10.3. Defining Our Own Functions
    1. 10.3.1. Function Syntax
      1. 10.3.1.1. Naming Functions
    2. 10.3.2. Function Code
    3. 10.3.3. Try It!
    4. 10.3.4. Defining vs. Calling
    5. 10.3.5. Check Your Understanding
  4. 10.4. Function Input
    1. 10.4.1. Arguments and Parameters
    2. 10.4.2. Mismatched Arguments and Parameters
    3. 10.4.3. Default Parameter Values
    4. 10.4.4. Check Your Understanding
  5. 10.5. Function Output
    1. 10.5.1. Return Statements
      1. 10.5.1.1. Returning a Value
      2. 10.5.1.2. No return Value
    2. 10.5.2. return Stops a Function
    3. 10.5.3. Try It!
    4. 10.5.4. Check Your Understanding
  6. 10.6. Boolean Functions
    1. 10.6.1. Try It!
  7. 10.7. A Good Function-Writing Process
    1. 10.7.1. Step 1: Design Your Function
    2. 10.7.2. Step 2: Create the Basic Structure
    3. 10.7.3. Step 3: Write the Body
  8. 10.8. Parameters and Variables
    1. 10.8.1. Function Scope
    2. 10.8.2. Variable Shadowing
    3. 10.8.3. Check Your Understanding
  9. 10.9. Functions Calling Other Functions
    1. 10.9.1. Palindrome Checker
      1. 10.9.1.1. The reverse_string Function
      2. 10.9.1.2. The is_palindrome Function
    2. 10.9.2. Functions Should Do Exactly One Thing
  10. 10.10. Why Create Functions?
    1. 10.10.1. Functions Reduce Repetition
    2. 10.10.2. Functions Make Your Code More Readable
    3. 10.10.3. Functions Reduce Complexity
    4. 10.10.4. Functions Enable Code Sharing
    5. 10.10.5. Functions Save Millions of Lives Every Day
  11. 10.11. Exercises: Functions
    1. 10.11.1. Part A: More Turtles
    2. 10.11.2. Part B: Return Values
    3. 10.11.3. Bonus Exercises
  12. 10.12. Project: Functions
    1. 10.12.1. Before You Start
    2. 10.12.2. Part A: Reverse Characters
    3. 10.12.3. Part B: Reverse Digits
    4. 10.12.4. Part C: Complete Reversal
    5. 10.12.5. Bonus Missions