CSC 1001 — Lab 9: AI Pair-Programming Lab
Intro
This lab has you work individually with an AI agent to design, prompt, trace, and debug a pricing tool, then compare your process and results with a partner.
| Section | Mode | What You'll Do |
|---|---|---|
| Individual | Individual | Design a solution, prompt an AI agent, trace and test its response, then fix and refine the code. |
| Communicate | Partner | Compare your AI-assisted process and results with a partner. |
Submit: your Lab 9 Worksheet (planning notes, prompts, trace table, and written answers) and your Lab9.ipynb notebook (commented, working code).
Individual
Problem: Campus Print Shop Pricing Tool
A student who runs a small print shop on campus has asked you to build a quick pricing tool. Here is what they told you, in their own words:
"I want something simple that tells me how much to charge for a print job. The customer tells me how many pages they need and whether they want color or black-and-white. Students get a discount. If it's a rush job, I need to charge extra. At the end I just want to see a clean summary of the charges and the total."
Given Requirements (translated from the client's request):
- The program should collect: number of pages, print type (
colororblack and white), whether the customer is a student (yes/no), and whether it's a rush order (yes/no). - Base price per page:
- Black and white: $0.10/page
- Color: $0.25/page
- Students receive a 10% discount on the page total (before the rush fee is added).
- Rush orders add a flat $5.00 fee after the student discount is applied.
- The program must display an itemized summary (page cost, discount if applied, rush fee if applied, and final total), formatted to two decimal places.
- The pricing calculation must live in at least one function that takes parameters and returns a value — it should not just be calculated inline in
main().
1. Where would you start?
Before you touch an AI tool, spend 5 minutes on paper or in a comment block. Answer:
- What are the inputs to this program, and what type is each one (string, float, bool)?
- What is the order of operations — does the discount apply before or after the rush fee? (Read requirement 3 and 4 again carefully.)
- What would you name the function(s) you need, and what would each one take in / return?
- Sketch this as pseudocode or a quick flowchart before writing a prompt.
Record your answers on your Lab 9 Worksheet.
2. Write a prompt to have AI help you write the solution
Remember: you are the author. The AI is just an assistant. A weak prompt just says "write me this program." A strong prompt gives the AI the same structured requirements you were given, plus your own design decisions from Step 1 (function names, parameter order, what should happen if the user types something invalid).
Write your prompt on your worksheet before you send it. Some options for AI include Claude, Copilot, Gemini, ChatGPT, Mistral Vibe, or GitHub Copilot.
3. Trace the AI response
Before you run anything, trace the code the AI gave you by hand, the same way you traced loops and functions in Weeks 6–8. Pick one representative test case (e.g., 12 pages, color, student, rush) and build a trace table on your worksheet: variable name, value at each step, and what gets printed.
4. Run the AI response
Run the code with the same test case you traced. Also test at least one edge case (e.g., 0 pages, or a non-student with no rush).
5. Does the AI response work? If not, how could you fix it?
Compare your hand trace and your requirements against the actual output. Common things to check:
- Did it apply the discount and rush fee in the correct order (requirement 4 says rush fee is added after the discount)?
- Did it actually use a function with parameters and a return value, or did it just calculate everything inline?
- Does it handle invalid input (e.g., user types "Color" with a capital C, or "yeah" instead of "yes")?
If something is wrong, fix it yourself — manually, using your Week 8 debugging process (identify error type → isolate → fix → verify). Document the bug and your fix on your worksheet.
6. Does the AI response make sense to you? If not, how could you fix it?
Even if the code runs correctly, that's not the same as being readable. Would a classmate be able to understand what each function does without you explaining it out loud? Are variable names clear? Is there a docstring on the function? Also think about if the AI did more than you asked. Is the code significantly longer or more complex than you would write? Why is that?
7. Change your prompt if necessary
If you had to fix a bug or rewrite something for clarity, go back and revise your original prompt so that it would have avoided that problem. On your worksheet, write your revised prompt and one sentence on what kind of problem you were correcting:
- Framing (the AI misunderstood the goal or requirements)
- Code (the logic or syntax was wrong)
- Documentation (missing/unclear docstring, comments, or variable names)
- Something else
Comments
If the AI-generated code doesn't already have comments, add your own now in Lab9.ipynb, explaining in your own words what each part of the code does — not just restating the code line by line, but explaining why it's there.
Reflection: What is AI good at helping with? What is AI poor at helping with?
Write 3–5 sentences based on this specific experience (not a general opinion) on your Lab 9 Worksheet. Be specific: point to the actual bug, framing issue, or documentation gap you ran into.
Communicate
Partner A (someone who used a different AI tool than you)
- How did your two responses differ (code structure, correctness, style, comments)?
- Which version do you trust more, and why?
Partner B (someone who used the same AI tool as you)
- How did your two responses differ, even though you used the same tool?
- Why might the responses differ even with the same tool?
- If they didn't differ, why not?
Record your answers on your Lab 9 Worksheet.
Submit: your Lab 9 Worksheet (planning notes, prompt(s), trace table, and written answers) and your Lab9.ipynb notebook (commented, working code).