Question

Pseudocode & Python In this portion of the project you will analyze a problem and create...

Pseudocode & Python

In this portion of the project you will analyze a problem and create a Python program to solve it.

In recent years, there has been more attention to Water Quality. Specifically the amount of lead that is found in our daily water supply. Lead and copper residue start to show up in our water supply due to aging pipes. This residue can be found in older homes that have not replaced their pipes and in the municipal water supply. What this means is even if you have a new home or newer pipes, you can still have higher amounts of lead or copper in your water due to the age of the pipes that carry your water to your house.

According to the EPA, it is important to monitor your drinking supply on a regular basis. If lead concentrations exceed 15 ppb (parts per billion) and copper exceed 1.3 ppm (parts per million), corrective action may be necessary.

A group of environmental scientists have embarked upon a study of your area’s water supply. They have divided the area into 4 sections: north, south, east and west. Within each section they have gathered water samples from 4 buildings. They have given you the data and are now asking you to create a program that will analyze the data.

Requirements

Create a Python program that will do each of the following:

List the names of each zone along with the measurement of lead and copper.

List the average lead and copper measurements.

List the average lead and copper measurements by zone.

List those buildings that have lead and copper values equal to or greater than the allowable values listed above.

List those buildings that have lead and copper values below the allowable values listed above.

They would like the program to offer a menu of options so that they can run whatever portion of the program they want at any given time. The menu should look like the following:

Select one of the options listed below:

P == Print Data

A == Get Averages

AZ == Average Per Zone

AL == Above Levels by Zone

BL == Below Levels

Q == Quit

Your program must use functions defined by you.

Some Help With the Logic

As with all programming projects it is important to plan out what your program needs to do. Begin by decomposing the problem keeping in mind that each part of the decomposition will represent a function/module. For each item listed in the decomposition, detail what that function/module of the code needs as far as data. Does the module need data? Does the data need to change while the module is working and does that change need to be reflected in the rest of the code? Does your module return data? And finally, what does each module do or try to accomplish.

Once you have completed your planning document, open up the file in week 13 of Canvas that reads: Water Quality Template.py. Begin by composing the loop that will allow the program to keep running in main(). Then start coding your functions. After you write each function, place your function call in main() and test your program. Expected output is listed towards the end of this guide sheet.

Program Requirement & Grading

Your program NEEDS to follow the rules listed below:

All code must reside in functions. Each item listed in the menu has to have its own function. Code outside of a function or main() will not be considered for grading.

Do not use GLOBAL or attempt to declare global variables.

Do not alter or change the lists in any way. As you need to move them throughout your program, how they appear in main() is how they need to be used. Do not attempt to splice the lists into segments.

Declare and use local variables and practice good naming conventions.

Do not declare any more variables in main(). What you see in the template is all you will need.

Contain your print statements to the individual functions.

Include comments in your code.

Make sure you consult with the rubric prior to turning in your assignment to make sure you have not missed anything.

Expected Output

What follows below is a series of outputs when the user selects the various items in the menu. Try to get your output to look as similar as possible to what is listed below.

When entering P:

Lead and Copper Water Study

Zone                Lead    Copper

****************************************

North 1            10        0.03

North 2            13        0.25

North 3            5          1.4

North 4            16        0.15

East 1              17        0.37

East 2              8          0.85

East 3              3          1.5

East 4              2          0.99

West 1             6          0.55

West 2             9          1.1

West 3             11        0.97

West 4             8          0.77

South 1           4          0.82

South 2           7          0.74

South 3           6          0.96

South 4           5          1.1

When entering A:

Average Levels of Lead and Copper

*****************************************

Lead Average:            8.12

Copper Average:        0.78

When entering AZ:

Average Values by Zone

********************************

LEAD Averages by Zone

********************************

North               11.00

East                 7.50

West                8.50

South              5.50

COPPER Averages by Zone

********************************

North               0.46

East                 0.93

West                0.85

South              0.91

When entering AL:

Zones Above Safe Levels

**********************************************

Lead Zones Above Acceptable Levels

**********************************************

North 4            16

East 1              17

Copper Zones Above Acceptable Levels

**********************************************

North 3            1.4

East 3              1.5

When entering BL:

Zones Below Safe Levels

**********************************************

Lead Zones Below Acceptable Levels

**********************************************

North 1            10

North 2            13

North 3            5

East 2              8

East 3              3

East 4              2

West 1             6

West 2             9

West 3             11

West 4             8

South 1           4

South 2           7

South 3           6

South 4           5

Copper Zones Below Acceptable Levels

**********************************************

North 1            0.03

North 2            0.25

North 4            0.15

East 1              0.37

East 2              0.85

East 4              0.99

West 1             0.55

West 2             1.1

West 3             0.97

West 4             0.77

South 1           0.82

South 2           0.74

South 3           0.96

South 4           1.1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def GetChoice():

user_choice = str()

print()

print("Select one of the options listed below: ")

print("\tP\t==\tPrint Data")

print("\tA\t==\tGet Averages")

print("\tAZ\t==\tAverage Per Zone")

print("\tAL\t==\tAbove Levels by Zone")

print("\tBL\t==\tBelow Levels")

print("\tQ\t==\tQuit")

print()

user_choice = input("Enter choice: ")

print()

user_choice = user_choice.upper()

return user_choice

def printData(zones,lead,copper):

print("Zone\tLead\tCopper")

print("***************************")

for i in range(len(zones)):  

print(zones[i], " ", lead[i], " ", copper[i])

def averageLevels(lead,copper):

sum = 0  

print("Average Levels of lead and copper")

print("**********************************\n")

for i in range(len(lead)):

sum += lead[i]

avg = sum / len(lead)  

print("Lead Average:\t",round(avg,2))

sum = 0  

for i in range(len(copper)):  

sum += copper[i]

avg = sum / len(copper)  

print("Copper Average:\t", round(avg,2))

def averageByZone(lead, copper):

sum = 0  

avg = []  

print("Averages Values By Zone")

print("***************************\n")

print("LEAD Averages by zone")

print("***************************\n")

for i in range(len(lead)):  

sum += lead[i]  

if (i + 1) % 4 == 0:  

avg.append(sum / 4)  

sum = 0  

print("North\t",round(avg[0],2))

print("East\t", round(avg[1],2))

print("West\t", round(avg[2],2))

print("South\t ", round(avg[3],2))

avg = []

print("\nCOPPER Averages by zone")

print("***************************\n")

for i in range(len(copper)):  

sum += copper[i]

if (i + 1) % 4 == 0:  

avg.append(sum / 4)  

sum = 0  

print("North\t", round(avg[0], 2))

print("East\t", round(avg[1], 2))

print("West\t", round(avg[2], 2))

print("South\t ", round(avg[3], 2))

def aboveLevel(zones,lead,copper):

leadAbove = 15  

copperAbove = 1.3  

print("Zones Above Safe Levels")

print("***********************\n")

print("Lead Zones Above Acceptable Levels")

print("***********************************\n")

for i in range(len(lead)):  

if lead[i] >= leadAbove:  

print(zones[i], " ", lead[i])

print("\nCopper Zones Above Acceptable Levels")

print("***********************************\n")

for i in range(len(copper)):

if copper[i] >= copperAbove:  

print(zones[i], " ", copper[i])

def belowLevel(zones,lead,copper):

leadBelow = 15

copperBelow = 1.3

print("Zones Below Safe Levels")

print("***********************\n")

print("Lead Zones Below Acceptable Levels")

print("***********************************\n")

for i in range(len(lead)):  

if lead[i] < leadBelow:  

print(zones[i], " ", lead[i])

print("\nCopper Zones Below Acceptable Levels")

print("***********************************\n")

for i in range(len(copper)):  

if copper[i] < copperBelow:

print(zones[i], " ", copper[i])

def main():

zones = ["North 1", "North 2", "North 3", "North 4", "East 1 ", "East 2 ", "East 3 ", "East 4 ", "West 1 ",

"West 2 ", "West 3 ", "West 4 ", "South 1", "South 2", "South 3", "South 4"]

lead = [10, 13, 5, 16, 17, 8, 3, 2, 6, 9, 11, 8, 4, 7, 6, 5]

copper = [0.03, 0.25, 1.4, 0.15, 0.37, 0.85, 1.5, 0.99, 0.55, 1.1, 0.97, 0.77, 0.82, 0.74, 0.96, 1.1]

choice = str()

while True:

choice = GetChoice()

if choice == 'P':

printData(zones, lead, copper)

if choice == 'A':

averageLevels( lead, copper)

if choice == 'AZ':

averageByZone(lead, copper)

if choice == 'AL':

aboveLevel(zones, lead, copper)

if choice == 'BL':

belowLevel(zones, lead, copper)

if choice == 'Q':

break

main()

OUTPUT:

elect one of the options listed below: Print Data Get Averages Average Per Zone Above Levels by Zone Below Levels Quit AZ AL BL. Enter choice: P Zone Lead Copper North 1 North 2 North 3 North 4 East1 East 2 East 3 East 4 West 1 West2 West 3 West 4 10 13 0.03 0.25 16 ?. 15 17 0.37 0.85 1.5 0.99 0.55 1.1 3 2 6 0.97 0.77 th 1 0.82 outh 2 outh 3 South 4 0.74 0.96 1.1

Add a comment
Know the answer?
Add Answer to:
Pseudocode & Python In this portion of the project you will analyze a problem and create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Starting in Albany, you travel a distance 370 miles in a direction 37.8 degrees...

    QUESTION 1 Starting in Albany, you travel a distance 370 miles in a direction 37.8 degrees north of west. Then, from this new position, you travel another distance 348 miles in a direction 21.1 degrees north of east. In your final position, what is your displacement from Albany? 354 miles 84.8 degrees North of West 718 miles 58.9 degrees North of East 537 miles 38.2 degrees North of West 718 miles 58.9 degrees North of West QUESTION 2 You start...

  • % Create a matrix which has 150 rows and 200 columns % Use the rand function...

    % Create a matrix which has 150 rows and 200 columns % Use the rand function to generate that matrix with radom values of entries % are between 0 and 1 a = rand(150,200); b = zeros(1,300); for i = 1:150     for j = 1:200         if rand() < 0.9 % 90% of rand() value less than 0.9             a(i,j) = 0; % Assign 0 for dead cells         else a(i,j) = 1; % Assign 1 for living cells...

  • C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to...

    C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to store the following data on a company division: Division Name (East, West, North, and South) Quarter (1, 2, 3, or 4) Quarterly Sales The user should be asked for the four quarters' sales figures for the East, West, North, and South divisions. The data for each quarter for each division should be written to a file. The second program will read the data written...

  • In this graded tutorial you will learn how to use Excel’s INDEX and MATCH functions. If you are familiar with the VLOOKUP function, INDEX/MATCH is often seen as a better method to accomplish the same...

    In this graded tutorial you will learn how to use Excel’s INDEX and MATCH functions. If you are familiar with the VLOOKUP function, INDEX/MATCH is often seen as a better method to accomplish the same goal. The Excel INDEX function returns a value in a range based on the row and/or column numbers that are specified. Its format is INDEX(array, row_num, [column_num]). Note that column_num is optional. For example, assume you have the simple data below: A B 1 North...

  • 2.You start out by driving 91 miles south in 2 hours and 43 minutes, and then...

    2.You start out by driving 91 miles south in 2 hours and 43 minutes, and then you stop and park for a while. Finally you drive another 76 miles north in 2 hours and 50 minutes. The average velocity for your entire trip was 2.16 miles per hour to the south. How much time did you spend parked? 0 hours 41 minutes 6 hours 56 minutes 1 hours 23 minutes 2 hours 46 minutes 3.A rocket-powered sled moves along a...

  • If you can show me step-by-step, I would greatly appriciate that BACK NEXT Pool 21.1: Quito...

    If you can show me step-by-step, I would greatly appriciate that BACK NEXT Pool 21.1: Quito is the capital city of Ecuador in South America and locate... Quito is the capital city of Ecuador in South America and located near the equator. The Earth's magnetic field near Quite is horizontal and points north the magnetic force exerted on a proton traveling near Quito is directed due east, what is the direction the proton is moving? south east west vertically downward...

  • 1) How would you describe thunder and the light from lightening as waves? -A) Thunder longitudinal,...

    1) How would you describe thunder and the light from lightening as waves? -A) Thunder longitudinal, lightening transverse -B) Thunder transverse, lightening transverse -C) Thunder transverse, lightening longitudinal -D) Thunder longitudinal, lightening longitudinal 2) Suppose the longitudinal component of a wave created by an earthquake is travelling from east to west. As it passes through your position, how would you expect to move? -A) Both up and down, and north and south -B) east and west -C) north and south...

  • Directions: Create a structure that contains the following data: DivisionName First-QuarterSales Second Quarter Sales Third Quarter...

    Directions: Create a structure that contains the following data: DivisionName First-QuarterSales Second Quarter Sales Third Quarter Sales Fourth Quarter Sales Total Sales Average Sales Create an enumerated data type of {North,South,East,West} Create an array of this structure with one instance for each enumerated data type listed above. Write a C++ program that will create a menu driven program with the following options: Menu Options: A) Add Data B) Compute Total Sales and Avg Sales C) Display Data D) Division Highest...

  • #2 You are going to add more code to carClass.cpp. 0. Make sure you finished the...

    #2 You are going to add more code to carClass.cpp. 0. Make sure you finished the lab part: goForward, turnRight(), getDirection(), getXO, getY() and get Modelo 1. Preparation: In the last lab, we tested our functions using cl. Comment out that section. Create c2 with any make and model. int main() Car cl("Toyota", "Camry") 77777777777777 lereate c2 here Tested the functions in the last lab cout <<cl.getModel() << endl; Comment out this section cout <<cl.getX() <<"*«<cl.getY() << endl; return 0;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT