Example

Example of a Prompt and Completion for a Python Average Function

When instructing a language model trained on language and code to perform a code completion task, a prompt such as 'Please write a Python function to calculate the average of a list of numbers.' can be used. The model completes the prompt by generating the corresponding code block, such as a calculate_average function that gracefully handles both populated and empty lists by returning the sum divided by the length, or 0 if empty.

0

1

Updated 2026-04-30

Contributors are:

Who are from:

Tags

Foundations of Large Language Models

Ch.3 Prompting - Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences