Prompting AI as Your Coding Buddy
Explore how to collaborate with AI as a coding partner by learning how to prompt it for generating and refining Python code. Understand the importance of clear instructions to get useful outputs and use AI to experiment, compare, and solve coding challenges alongside your own programming efforts.
We'll cover the following...
What is prompting?
Coding in Python isn’t something you do alone. You’ve got a partner: an AI that can write code, explain, and help you debug.
But just like learning a new language, how you ask questions matters. Think of prompting as giving instructions to a very fast, very patient helper.
By the end of this lesson, you’ll know how to:
Ask the AI for code.
Refine your request.
Use the AI to explore and experiment, not just copy answers.
First prompt
Try asking the AI:
“Write Python code that prints 2 + 3.”
You’ll get a small snippet of code. Run it. That’s somewhat similar to what you created in the previous lesson, but now the AI did what you wanted to do.
Food for thought:
What did the AI give you?
Was it exactly what you asked for?
Did it add extras (like comments or explanations)?
Refining your prompt
Now, tweak your request (In the same AI buddy widget where you prompted earlier):
“Change it to print the result of 2 + 3, not just the text.”
Run it. Did the code change? Did it match your expectations?
If not, adjust your words. Try:
“Make it print the result with a message: The answer for 2+3 is 5.”
Notice how adding or changing just a few words makes the AI adapt.
Why this matters to you
As you move through this chapter, you’ll:
Write your own code first.
Then use prompting as a learning supplement: to compare, to experiment, or to get unstuck.
Now you’ve learned how to talk to your coding buddy.
Next, we will build a capstone project, but this time with AI as our copilot.