CommencerCommencer gratuitement

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

Cet exercice fait partie du cours

AI-Assisted Coding for Developers

Afficher le cours

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.

Exercice interactif pratique

Passez de la théorie à la pratique avec l’un de nos exercices interactifs

Commencer l’exercice