Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DDI&T a Python program to input, store, and process hourly temperatures for each hour of the day (i.e., 24 temperatures). Your program should be divided

DDI&T a Python program to input, store, and process hourly temperatures for each hour of the day (i.e., 24 temperatures). Your program should be divided logically into the following parts:

In function main() declare an empty List container:

HourlyTemperatures = []

Pass the empty HourlyTemperatures list to a function,

GetTemperatures(HourlyTemperatures)

This function must interactively prompt for and input temperatures for each of the 24 hours in a day (0 through 23). For each temperature that is input, verify that its value lies in the range of minus 50 degrees and plus 130 degrees (i.e., validate your input values). If any value is outside the acceptable range, ask the user to re-enter the value until it is within this range before going on to the next temperature (HINT: use a nested loop (e.g., Pythons equivalent to a do-while loop) that exits only when a value in the specified range has been entered). Store each validated temperature in its corresponding element of the list container passed as a parameter to the function (Hint: Look at the append() function that can be called on a list container).

Next pass the filled list container to a function,

ComputeAverageTemp(HourlyTemperatures)

This function computes the average temperature of all the temperatures in the list and returns this average to the calling function.

Finally, pass the filled list container and the computed average temperature to another function,

DisplayTemperatures(HourlyTemperatures, AverageTemp)

which displays the values of your temperature list in a columnar format followed by the values for the high temperature, low temperature, and average temperature for the day. NOTE: If you want to create separate function(s) to find and return the high and low temperature values, then feel free to do so!

The resulting output should look something like this:

Hour Temperature

00:00 42

01:00 42

. . . . . . . . // Your program output must include all of these too!

22:00 46

23:00 48

High Temperature: 68

Low Temperature: 42

Average Temperature: 57.4

5. Since you have several created functions to perform each of the major steps of your solution, your main(): function should be quite simple. The pseudo code for main() might look something like this:

main()

#declare any necessary variable(s) and HourlyTemperatures list

while user-wants-to-process-another-days-worth-of-temperatures

call GetTemperatures(HourlyTemperatures)

call ComputeAverageTemp(HourlyTemperatures)

call DisplayTemperatures(HourlyTemperatures, AverageTemperature)

ask if user want to process another days worth of temperatures

6. Test your program with at least two (2) different sets of temperatures. Make sure you enter values to adequately test your temperature-validation code (e.g., temperatures below 50 and above +130 degrees).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago