Prompt Engineering Lesson Plan for Computer Science Students
Objective: To introduce computer science students to the concept of Prompt Engineering (PE) and provide a foundational understanding of how to create effective programming and coding prompts.
Steps:
Understanding Prompt Engineering (PE) for Computer Science (20 minutes): Begin by providing a comprehensive explanation of Prompt Engineering (PE) tailored to computer science. PE is a systematic process used in computer science education to design and refine programming prompts or coding assignments that improve the quality of code, problem-solving, and understanding of algorithms.
Compare PE to designing the specifications for a software project. Just as a well-crafted project specification document guides software development, PE helps us design clear and effective coding prompts that guide students in solving complex programming problems.
Provide an example: Imagine you're teaching a data structures and algorithms course. An effective prompt in this context would specify a problem statement, input/output requirements, and expected algorithmic complexity. This clear prompt ensures that students understand the task's expectations.
Importance of PE in Computer Science Education (15 minutes): Emphasize why PE is essential in computer science education. In computer science, precision, clarity, and adherence to coding standards are critical. Effective prompts are necessary for guiding students toward successful problem-solving and coding practices.
Analyzing Sample Coding Prompts (20 minutes): Provide computer science students with a set of sample coding prompts or programming challenges from various domains, such as data structures, algorithms, or software engineering. In groups, have them dissect and identify the key components of each prompt, including the problem description, input/output specifications, and constraints.
Discussion on Coding Challenges (15 minutes): Engage computer science students in a discussion about common challenges they've encountered in coding prompts or programming assignments. Use the following discussion prompts:
1. Can you recall a coding assignment or prompt that you found particularly challenging? What aspects of the prompt made it difficult to approach?
2. Have you ever encountered a coding prompt that lacked clarity or didn't align with coding standards? How did it impact your approach to the assignment?
3. Conversely, can you think of a coding prompt that was exceptionally clear and effective? How did it contribute to your understanding and success in the assignment?
4. What do you believe are the essential components of a well-crafted coding prompt? What elements should it include to guide you effectively in coding and problem-solving?
5. How do you think understanding the concept of PE and applying it to coding prompts can improve your coding skills and overall computer science education?
Guided Prompt Engineering for Computer Science (30 minutes): Present a coding prompt or programming challenge relevant to the course's objectives. Work together as a class to dissect the prompt and discuss its components. Collaboratively revise the prompt to make it clearer, more specific, and aligned with effective coding practices and problem-solving.
Ineffective Prompt (Example): "Write a program to sort a list."
Problems: This prompt is overly general and lacks details about the list, sorting algorithm, or any constraints.
Properly Edited Prompt (Example): "Implement the merge sort algorithm to sort a list of integers in ascending order. Your program should have a time complexity of O(n log n) and handle lists with up to 1,000,000 elements efficiently."
Improvements: The edited prompt specifies the sorting algorithm (merge sort), the type of data (integers), the desired order (ascending), and constraints (time complexity, list size), providing clear guidance to students.
Individual PE Practice for Computer Science (20 minutes): Assign computer science students a challenging coding prompt or programming problem related to the course material. Have them apply what they've learned about PE to revise the prompt individually, making it more specific and aligned with effective coding practices and problem-solving strategies.
Peer Review for Coding Prompts (15 minutes): Have computer science students exchange their revised coding prompts with peers. They can provide feedback on clarity, alignment with objectives, and potential improvements in coding and problem-solving tasks.
Wrap-Up and Application (10 minutes): Summarize the key takeaways from the lesson and emphasize the importance of PE in computer science education. Encourage computer science students to apply these skills to real-world coding challenges and assignments they may encounter in their academic and professional careers.
Example Coding Prompts:
Ineffective Prompt: Write a program to calculate the sum of numbers in a list.
Problems: This prompt is overly general, lacks specific details about the list, and doesn't specify whether the program should be in a particular programming language.
Properly Edited Prompt: Implement a Python program to calculate the sum of integers in a given list. The program should handle both positive and negative integers and provide the result as the output.
Improvements: The edited prompt specifies the programming language (Python), the data type (integers), the expected behavior (calculating the sum), and the output format, making it clear and guiding students effectively.
Ineffective Prompt: Create a function to sort data.
Problems: This prompt is overly vague and doesn't indicate the type of data, sorting criteria, or programming language to be used.
Properly Edited Prompt: Write a Java function that implements the quicksort algorithm to sort an array of integers in ascending order. The function should have a time complexity of O(n log n).
Improvements: The edited prompt specifies the programming language (Java), the sorting algorithm (quicksort), the data type (integers), the desired order (ascending), and the expected time complexity, providing clear guidance.
Ineffective Prompt: Code a program to find a solution.
Problems: This prompt is overly vague and doesn't specify the problem to be solved, the input data, or the expected output.
Properly Edited Prompt: Write a Python program to find the two numbers in an array that add up to a specific target value. The program should return the indices of the two numbers.
Improvements: The edited prompt specifies the programming language (Python), the problem statement (finding two numbers that add up to a target), the input data (array), and the expected output (indices), providing clear guidance to students.
Ineffective Prompt: Develop a software application.
Problems: This prompt is overly broad and doesn't specify the type of software, its features, or the programming language to be used.
Properly Edited Prompt: Create a web-based weather forecasting application using JavaScript and the OpenWeatherMap API. The application should allow users to input a location and display current weather conditions.
Improvements: The edited prompt specifies the type of software (weather forecasting application), the programming language (JavaScript), the external data source (OpenWeatherMap API), and the expected features, providing clear guidance to students.