Four short programs. Every one of them is broken. Your job is to find the mistake, say what kind of mistake it is, and fix it.
You did not write these, which is the point. Reading someone else's broken code is a different skill from writing your own, and it is the one you will use most.
Not every bug looks the same, and the difference matters because it changes how you hunt for it.
Logic errors are the dangerous ones, because nothing warns you. The only way to catch them is to know what the answer should be and notice that it isn't.
When Python reports a syntax error, it tells you the line where it noticed something was wrong — not always the line where you made the mistake. Those are often different lines, and sometimes Python blames a line number that doesn't even exist in your file.
So treat the line number as a starting point, not an answer. Look at the line it names, then look upward.
For each one, copy it into a Python file and run it. Then write down:
Symptom: this program refuses to run at all.
price = 19.99quantity = 3print("Total:", price * quantityExtra question, and it is the important one: which line number does Python blame, and is that the line where the mistake actually is?
Symptom: it runs and prints Area: 20. The rectangle is 12 by 8, so the area should be 96.
length = 12width = 8print("Area:", length + width)Symptom: it runs and prints Average: 206.33333333333334. The average of 88, 92, and 79 should be about 86.33.
score1 = 88score2 = 92score3 = 79print("Average:", score1 + score2 + score3 / 3)Hint: the number it printed is far too big. Which part of that line does Python do first?
Symptom: it runs and prints Dollars: 12.5. This program is supposed to report how many whole dollars are inside 1250 cents, which is 12.
cents = 1250print("Dollars:", cents / 100)For each of the four bugs, submit:
Plus your answer to Bug 1's extra question about the line number.
Three of these four are logic errors. If you found yourself waiting for an error message on those, that is exactly the habit this challenge is meant to break.