Lesson 2 (AI): Prompt Engineering
AI models are powerful, but they need clear instructions. Writing these instructions is called Prompt Engineering.
Python is perfect for automating the creation of complex prompts by combining pieces of text (strings).
The Prompt Formula
A good prompt has: Role + Context + Task.
role = "You are a cooking expert."
task = "Give me a quick recipe."
prompt = role + " " + task
Your Objective
We created a message generator. Modify the variables to change the tone of the response.
- Change the
tonevariable (e.g., "formal", "pirate", "alien"). - Run the code and see how Python constructs the final sentence.