Using AI to Iterate on a Programming Task
Summary:
Statistics Professor Rich Ross shares an activity students can do in class to help them learn about writing effective prompts and verifying the results of AI-powered solutions.
Sometimes, I can give students a simple programming task. Let’s suppose I want them to combine two datasets together, then use the resulting combined data to make a scatterplot. Then, we feed that code into ChatGPT and ask the AI to embellish the existing code to make a fancier, more complicated plot. This can sometimes go very right and sometimes go very wrong. This is a great activity to do in class, and then students or groups of students can show off their best or worst results.
Here's an example of the first version of code used to generate a plot, and the plot:


I then added to the ChatGPT conversation:
can you embellish that code to make a more elegant plot? I'd like the plot to have a title, add color to the points based on the "clarity" variable, and add one more embellishment of your choice.
The resulting code and plot are shown here:


This embellished plot does a lot of things right, but still needs some tweaking, which students can finish up on their own!
Activities such as this one help students learn how to write effective prompts, how to verify the results of AI-powered solutions, and the potential to use ChatGPT as part of an iterative process in creating great work.