Debugging short exercise
From WLCS
Objective: Practice debugging techniques
This program is supposed to break once the ball has been caught, but it doesn't work. Your job is to work out why, and then fix it.
- Download media:Catch-debug-exercise.py and open it in Dr. Python
- Add print statements to trace program execution
print "Trace: At start"
- Start of the program
- Once the game window has been created
- Inside of the main game update loop
- Inside of the if statement that checks if the ball has been caught
- End of program
- Run the program and stop it as soon as the buggy behavior has occurred.
- Analyse the console output (the debug 'trace').
What would you expect to see if the program was running properly? - Is the problem that the distance isn't being properly calculated?
Add another print statement that prints it. - Once you've worked out what the real problem is, fix it.
- Submit your code to school web locker