You define a function with the def keyword, followed by the function name, a pair of parentheses containing any parameters, and a colon. The indented block below is the function body, and it must contain at least one statement (pass will do). Defining a function does not run the body; it creates a function object and binds it to the name. The body runs only when you call (invoke) the function by writing its name followed by parentheses, with any arguments inside. Each call runs the body from the top, with fresh local variables.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.