Aan de slagGa gratis aan de slag

Code generation with problem description

You work as an analyst for a retail company and analyze monthly sales data. You need to develop a Python function that accepts a list of 12 numbers representing sales for each month of the year and outputs the month with the highest sales value. This information will help your company identify the most profitable month. You feed the problem description to a language model to get help.

The OpenAI package and the get_response() function have been pre-loaded for you.

Deze oefening maakt deel uit van de cursus

Prompt Engineering with the OpenAI API

Cursus bekijken

Oefeninstructies

  • Craft a prompt that asks the model to write a Python function that receives a list of 12 floats representing monthly sales data as input and, returns the month with the highest sales value as output.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

client = OpenAI(api_key="")

# Craft a prompt that asks the model for the function
prompt = ____

response = get_response(prompt)
print(response)
Code bewerken en uitvoeren