LLM Programming Exercises
What do you do when teaching programming with LLMs that isn’t in this list?
- Critically review AI output.
- Have the LLM answer a programming question or explain a concept, then ask learners to review its response collectively for correctness, clarity, and omissions, testing claims against examples or documentation.
- Predict, solve, and compare.
- Have learners predict what code an LLM will generate for a problem (or solve it independently), then compare their work with the AI-generated solution and explain the differences.
- Debug and minimally repair code.
- Give learners a deliberately flawed program, tell them it was generated by AI (even if it wasn’t), and ask them to identify, explain, and find the smallest possible fix for each bug without initially asking the AI for help.
- Compare and rank multiple solutions.
- Have the LLM generate several different solutions to the same programming problem, then have learners compare them for correctness, readability, and efficiency.
- Guided discovery.
- Have learners prompt the LLM to provide only progressively stronger hints or Socratic questions rather than complete solutions.
- Code translation.
- Give learners a short program in one language and prompt the LLM to translate it into another, then have learners annotate the translation to identify which programming concepts carried over and which changed.
- Test the tests.
- Prompt the LLM to generate test cases for a learner’s function, then have learners determine which are redundant and what edge cases the AI missed.
- Prompt improvement.
- Give learners a vague programming prompt and have them iteratively refine it for an LLM, comparing how changes affect the resulting code.
- Understand unfamiliar code.
- Give learners a large program without explanation and have them explore its structure and purpose using an LLM.
- Fill in the blanks.
- Give learners an incomplete program and have the LLM suggest several possible completions for learners to evaluate and test.
- Error-message dialogue.
- Have learners paste compiler or runtime error messages into an LLM, predict what advice it will give, and then assess whether that advice actually fixes the underlying problem.
- Spot the hallucination.
- Give learners explanations containing a mixture of correct and invented “facts” and have them use experiments and documentation to identify the false claims.
- Refactor and improve.
- Have learners refactor poorly structured or badly written code, then compare their changes with an LLM’s suggestions and defend their design choices.
- Test-driven AI.
- Have learners write the expected behavior and test cases for a function before prompting an LLM to implement it, then use the tests to evaluate and revise the generated code.
- Role reversal.
- Have learners write a program and prompt the LLM to act as a novice programmer who misunderstands it, then identify and correct the misconceptions in the AI’s interpretation.
- AI-generated homework critique.
- Have learners prompt an LLM to generate a beginner programming exercise, then critique whether the problem is well-designed.
- Rubric construction.
- Have learners prompt an LLM to propose a grading rubric for a programming assignment, then revise it as a class to make the criteria clearer and more meaningful.
- Concept misconception.
- Prompt an LLM to explain a programming concept as if it held a common beginner misconception, then have learners diagnose and correct the misconception.
- Documentation detective.
- Give learners documentation for a small program and have them inspect the actual code to find statements in the documentation that are unsupported or incorrect.
- Prompt versus program.
- Have learners solve a problem once by writing code and once by carefully prompting an LLM, then discuss which parts of computational thinking are shared between the two approaches.
Categories:
education, software-engineering