CSC 171 - Introduction to Computer Programming

Lab Assignment #7 - Counting Loops Containing a Decision

Due Wednesday, September 27, 2023

Last time, we saw that we can use a binary decision to specify a counting loop. We can expand that so that we can incorporate a decision within our counting loop. In the flow chart below, we will have two decisions: one to implement a counting loop and another to implement a binary decision, as we prepare to find a series of absolute values. Please keep in mind that an absolute value for a positive number is the number itself. However, the absolute value for a negative number requires that either remove the sign or change the negative sign to a positive sign. Our flow chart looks like this:

The decision on the right side of the chart controls our loop, while the decision on the left control which of two methods we use to print the absolute value.

Create a Python program that will allow the user to enter a value n. The program will repeat the following sequence of instructions n times.

  1. Ask the user if (s)he is single or married.
  2. If the user is single, print that his/her tax rate is 35%. If the user is married, print that his/her tax rate is 32%.

You will submit a flowchart, pseudocode as well as the Python program

[Back to the Lab Assignment List]