Skip to main content

Section 12.4 Week 3 Lab

Note 12.4.1. Material Covered.

Python modules and debugging (Chapter 3)

Note 12.4.2.

When debugging a program, whether it be your own or someone else’s, it’s best to understand what the program is trying to do first. Read through the code and comments before editing the program. Also, when errors occur, it helps to start from the line number of the error and work your way backwards.

Subsection 12.4.1 Level 1

The program below contains multiple errors. Your objective is to debug the program, and match the expected output (see below the code). You can run the code to see error messages.

Note 12.4.3.

You do not need to delete any lines of code, only edit/add.
For the following inputs:
loan = 5000
time = 12
rate = 6.25
The program should print:
> Your annual compound interest is: 5349

Subsection 12.4.2 Level 2

The program below runs but contains multiple semantic (logic) and programmer errors.
Your objective is to debug the program, and match the expected output (see below the code).

Note 12.4.4.

There are three errors on three separate lines
For the following inputs:
income_2020 = 10000
income_2021 = 10000
The program should print:
> Your tax rate for 2020 and 2021 was 24.0 percent

Subsection 12.4.3 Level 3

The following is a screenshot of turtle output. The program uses three turtles: 2 white and 1 red.

Note 12.4.5.

The windows size is 400 pixels by 400 pixels (default size)
You must recreate the output using the following guidelines:
  • The white turtles have pen size is 1, while the red has pen size 2
  • The red turtle draws last
  • The red turtle draws a singular line at a random angle from 0-360 and a random length from 0 to 200
You have attempted of activities on this page.