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 contains one syntax error and two semantic (logic) 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 a dog weighing 7.7 kg, the output should look like:
For a dog weighing 16.94 pounds,
your vet will likely prescribe an amount of aspirin as follows:
84.7 milligrams one to 2 times per day.
Do not exceed the daily maximimum dosage of: 169.4 milligrams

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.