Lab activity – debugging
Please take a look at the attachment
CSS 225 Module 4 Lab Activity – Debugging
Deliverables:
Submit the corrected versions of each of the following programs:
· time.py
· pirate.py
· collections.py
· branching.py
· grading.py
· random.py
· time2.py
Common Errors and How to Find them:
With experience you will see that many errors that come up in code, from beginners to expert developers, are usually based on a few common types of problems:
Syntax: (ParseError) Check parentheses, quotations, brackets, if/elsif/else statements, braces, commas, etc.
Variables: (NameError) Be consistent with using your variable names. They should be defined before they are used for the first time. Use naming schemes that convey their use, so you know what they are meant to do.
Functions: (we haven’t covered functions yet, but for later) Know how the functions you are using work. What do they return?
If you get stuck, try these steps to help you through the debugging process:
1 – Use the print statement to print out variable values at different points. This will help you verify if they are returning what you are expecting to see.
2 – Check the coloring in your text editor (IDLE). If the colors don’t look like you would expect them to, that could be the place of the error.
3 – Check the error output in the terminal (shell).
4 – Work through sections of the code piece by piece. This will help you narrow your search.
5 – Read the Python documentation.
6 – Use commenting in your code. This will help make sure you understand what your code is doing.
7 – Ask for help!
Problems: For each given program, find the bug and fix it.