Prompt engineering basics

AI-Assisted Coding for Developers

Francesca Donadoni

AI Curriculum Manager, DataCamp

What is a prompt?

Prompt: The input or instruction we give to an AI model

32.png

AI-Assisted Coding for Developers

What is a prompt?

Prompt: The input or instruction we give to an AI model

33.png

AI-Assisted Coding for Developers

What is a prompt?

Driver: "Where to?"

Character: "Anywhere"

PROMPT: Vague, unclear for the model

35.png

AI-Assisted Coding for Developers

What is a prompt?

Driver: "Where to?"

Character: "Take me to 23 Main Street. Avoid the highway"

PROMPT: Detailed, clear for the model

36.png

AI-Assisted Coding for Developers

Prompt quality

$$

❌ Bad prompt

$$

"Fix this code"

$$

✅ Good prompt

$$

"Fix this Python function to handle division by zero errors. Keep the structure the same, and only change the except block"

AI-Assisted Coding for Developers

Prompt quality

$$

☺ Simple prompt

$$

"Generate a Python function to reverse a string"

$$

🤓 Advanced prompt

$$

"Generate a Python function that reverses a string, handles Unicode characters, and ignores trailing whitespace"

AI-Assisted Coding for Developers

Components of a prompt

components_of_a_prompt.png

Fix this Python function to handle division by zero errors. Keep the structure the same, and only change the except block.

AI-Assisted Coding for Developers

Components of a prompt

components_of_a_prompt_2.png

AI-Assisted Coding for Developers

Let's practice!

AI-Assisted Coding for Developers

Preparing Video For Download...