Below is some code that has been deliberately broken so that you can fix it.
The code is supposed to generate a random times tables quiz question and test you to see if you get the right answer:
- Fix all syntax errors
Hint: A syntax error means the code has broken the rules of the language. Work upwards from the line number in the error message to see what’s wrong or what’s missing.
exceptto display an error message instead of crashing if the user types in
Hint: find the line that will crash if you enter
potatoand surround it with
- Fix the logic error
Hint: At the moment the program tells you you got the question right when you got it wrong and vice versa.
On the next page you’ll get some ideas for projects where you can use exception handling to create your own projects