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.
This exercise is part of the course
Prompt Engineering with the OpenAI API
Exercise instructions
- 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
client = OpenAI(api_key="")
# Craft a prompt that asks the model for the function
prompt = ____
response = get_response(prompt)
print(response)