This week we'll be doing something a bit different - rather than writing your own code, you'll be helping to debug (fix) my code!
This week we'll have a brief problem set (only 3 questions this time) with some problems using lists and dictionaries. It's available under Quizzes on Learn@UW.
You will have two attempts on this quiz — I recommend trying the first time with paper and pencil. You are welcome to use the interpreter and LiClipse to check your work on the second attempt.
My code doesn't work. Help me fix it.
I want to use dictionaries for translating sentences into a number code (each letter becomes the corresponding number: a=1, b=2, etc.) and back. Case (upper vs lower) shouldn't matter.
There are at least 10 lines with one or more errors on them; some are syntax errors, some are logic errors. Find at least 8 errors, describe the error and how you might fix it.
In order to help me fix my code effectively, your bugs.txt file should contain lines like this, pointing out the code line which contains the error, what the error is, and how to fix it:
Line 1: print hello world Bug: Right now Python thinks hello and world are variables. Add quotes to make it a string. Fix: print 'hello world' Line 4: x += 5 Bug: NameError, x was never initialized. Fix: add x = 0 somewhere before line 4
You should have at least 8 of these, but there are definitely more than 8 bugs in this code!
As usual, you'll be handing in your lab work via the course Learn@UW dropboxes. Navigate to our 301 course page, and click the Dropbox link in the top navigation bar. You should see a dropbox for Program 8 - this is where you should hand in your bugs.txt file.
Note that the dropbox will close at noon on 31 March, so be sure to submit your files before then.
This part of the assignment is ungraded, but we'll be talking about the questions in class on 30 March. I recommend working through the problems on your own first, but you may collaborate with as many people as you want (since this part is just for you and doesn't count toward your grade).
> REVIEW QUESTIONS <
This is not intended to be similar to the length of a full exam, but questions are of comparable difficulty to the questions you will encounter on the exam.