Ista 130 Homework 2 Due June 5 Before Class 1 Debugging Toda
Ista 130 Homework 2due June 5 Before Class1 Debuggingtodays Homework
Ista 130 Homework 2due June 5 Before Class1 Debuggingtodays Homework
ISTA 130: Homework 2 Due June 5 before class 1 Debugging today’s homework deals with debugging. This is the process that occurs when you find out your code doesn’t work, and you try to figure out why. Download the file errors.py from D2L. This file contains a script with a number of errors in it. Some are programming language errors, which Python will report with error messages.
Others are logic errors – code that runs, but does not do what the programmer intended. Your task is threefold: 1. Determine which lines have an error 2. In a comment after the line, write down the type of error message Python gives (if any), and a brief description of why this line has a problem 3. Correct the error so that the program has the intended behavior For example, if the line of code is: 99bottles = 5 Python will give the error: File "
The code has 15 problems by my count; each will be worth 1 point (15 pt.). Any additional improvements to the code may be worth extra points (2 pt.). 2 What to turn in Submit your corrected errors.py script to the Homework 2 Dropbox folder in D2L: Total Points: 15 points possible Extra Credit: 2 points possible 1
Paper For Above instruction
Debugging and Correcting errors.py Script
The homework assignment focuses on debugging a Python script named errors.py provided on D2L. The primary objective is to identify and understand various programming errors—both syntax (language) errors and logical errors—in the code, and then correct them to ensure the script behaves as intended.
Understanding the Assignment
Students are instructed to thoroughly analyze the errors.py script, which contains approximately 15 errors. These errors may include syntax errors, runtime errors, or logic errors where code runs but does not produce the desired outcome. The task involves three crucial steps:
- Identify erroneous lines: Review each line and determine which lines contain errors.
- Comment the errors: For each erroneous line, add a comment immediately following the line describing the error type (such as SyntaxError) and a brief explanation of why the error occurs.
- Correct the errors: Edit the code to fix the issues so that the script accomplishes what is intended.
An example provided is a line with an invalid variable name starting with a digit, which causes a syntax error:
99bottles = 5 # SyntaxError: variable names can’t start with a number
which should be corrected to a valid variable name:
ninetyninebottles = 5 # Corrected variable name
If multiple errors of the same type occur consecutively, only the first needs to be commented, while the subsequent ones can be fixed without additional comments.
Submission Details
Students must submit their corrected errors.py script via the D2L Homework 2 Dropbox. The assignment is worth up to 15 points, with an additional 2 points available for extra improvements beyond basic corrections.
Careful debugging and correct implementation will ensure full credit. Accuracy in identifying and explaining errors, as well as clean, corrected code, is essential.