Index Ai Academy
Phase 0 · Tools · Python core

Functions

Package steps into reusable, testable pieces with inputs and outputs.

About 25 minutes · Free lesson

Start this lesson

Why it matters

AI code is built from small functions: one builds the prompt, one calls the model, one scores the reply. When you ask an AI assistant to change your code, functions are the pieces you talk about ("make buildprompt include the brand voice"). They also make code testable. The exercise checks in this academy work by calling your functions with known inputs and comparing what comes back.

What you'll be able to do

  • Define a function with parameters and call it with arguments
  • Hand a value back with return, and know when print is the wrong choice
  • Give parameters default values and call functions with keyword arguments
  • Explain why a variable created inside a function doesn't exist outside it

Before this lesson

Next in this phase: Comprehensions