Get startedGet started for free

Optimizing prompts for code documentation

You've been working at the banking company for a long time now, and have maintained a large Python codebase for years. Now, a new intern is joining, and you realize all that knowledge lives in your head. You decide to use an AI assistant to start documenting the codebase.

To test the feasibility of this approach, you decide to start with a single function, saved in interest.py, a file the LLM can read and use:

def calculate_interest(balance, rate, years):
  return balance * (1 + rate) ** years

This exercise is part of the course

AI-Assisted Coding for Developers

View Course

Exercise instructions

- Prompt the model to **add docstrings** to the function, **specify a standard** (e.g., Google style docstrings), and **require sections** for purpose of the function, arguments (names/types), return type, and optionally examples.

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise