Get startedGet started for free

Explaining code step by step

As a financial analyst at a consulting firm, you're tasked with analyzing investment portfolios and providing insights to clients. While reviewing a set of financial data files, you come across a Python function that seems related to analyzing portfolios, but you're unsure of its exact purpose. You decide to use chain-of-thought prompting to let the language model decipher it step by step.

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

This exercise is part of the course

Prompt Engineering with the OpenAI API

View Course

Exercise instructions

  • Craft a chain-of-thought prompt that asks the model to explain the provided function.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

client = OpenAI(api_key="")

# Craft a chain-of-thought prompt that asks the model to explain what the function does
prompt = ____
 
response = get_response(prompt)
print(response)
Edit and Run Code