Skip to content

Sep 21: Defining Functions, return

Meet in King 248

Learning Objectives

After today's class, you should be able to:

  • Describe the syntax of function definitions and function calls.
  • Explain the flow of execution from one function to another.
  • Write short functions that have parameters and return values.

Lesson Outline

Mini Lecture [15 min]

  • Functions have parenthesis
    • Example from algebra: \(f(x) = 2x\)
    • \(f\) is a function, \(x\) is a variable, \(2x\) is the result
  • Python keywords: def and return
    def double(number):
        return 2 * number
    
  • Examples

Practice [35 min]

Your To-Do List

  • Read the Week 5 guide and begin studying