Learn Before
Crafting an Effective Debugging Prompt
You are working with the Python script below, which is intended to calculate the average value from a list of numbers. When you run the script with the input [10, 20, 30, 40], you expect the output to be 25.0, but instead, it prints 10.0. Your task is to write a clear and effective prompt that you would submit to a large language model to help you identify and fix the error in your code.
0
1
Tags
Ch.2 Generative Models - Foundations of Large Language Models
Foundations of Large Language Models
Foundations of Large Language Models Course
Computing Sciences
Application in Bloom's Taxonomy
Cognitive Psychology
Psychology
Social Science
Empirical Science
Science
Related
A developer has written the Python function below to find the smallest number in a list of positive integers. When they test it with the list
[10, 3, 8, 5], the function incorrectly returns0instead of the expected3.def find_smallest_number(numbers): smallest_so_far = 0 for num in numbers: if num < smallest_so_far: smallest_so_far = num return smallest_so_farThey ask a large language model for help debugging it. Analyze the four potential responses from the model. Which response provides the most accurate and helpful explanation of the logical error?
Crafting an Effective Debugging Prompt
A developer is working on four different code snippets, each containing a bug. In which of the following scenarios would a large language model, trained on a vast corpus of code, be most effective at identifying and suggesting a fix for the error?