Question: How do we find the max and min? The basic concept is similar to counting that you have done multiple times: initialize a value before

 How do we find the max and min? The basic concept

How do we find the max and min? The basic concept is similar to counting that you have done multiple times: initialize a value before a loop and the update the value every time through the loop. Based on that concept here is the algorithm to find the minimum of a set of values: 1. Initialize minimum to be much larger than any data value in your data, e.g. 10**6. 2. When you consider each data item, if the data item is smaller than the current minimum, you have a new minimum (so update it). 3. After considering all data items your minimum will contain the smallest. The algorithm to find the maximum is a tiny variation. To find the average, add up all the values and count how many values there are. Divide those two to get the average. Hint: build this program incrementally 1. Begin by simply opening the file and printing every line now you know that you are correctly working with the correct file. 2. Next ignore the header lineuse either readline() before the loop or continue in the loop. 3. Next find the average of a column: collect a total and count, remembering to initialize before the loop. 4. Next find the minimum of a column using the algorithm above. 5. Continue in such small increments to do the remainder of the program. ? Demonstrate your completed program to your TA. On-line students should submit the completed program (named lab05a.py) for grading via the Mimir system. Part B: Create a data file The second task is to write that output to a file. The steps are 1. Open a file for writing, e.g. outfile = open("output.txt","w") 2. Whenever you print, include the argument file = outfile For example, if you previously had print(x) you will now have print(x, file = outfile) 3. Close the file, e.g. outfile.close() If you forget this step, nothing will be written to the file. Also, dont forget the parentheses. Copy your lab05a.py to lab05b.py and make those modifications to your lab05b.py file; test that the output file created is correct. ? Demonstrate your completed program to your TA. On-line students should submit the completed program (named lab05b.py) for grading via Mimir system.

This lab exercise provides practice with file processing You will work with a partner on this exercise during your lab session. Two people should work at one computer. Occasionally switch the person who is typing. Talk to each other about what you are doing and why so that both of you understand each step Part A: Data Processing Given a data file, find the max, min, and average values of columns. Also, create an addition column that is based on the other columns. There will be no error checking required for this lab You are provided with a data file named (surprise!) data.txt. Data is arranged in columns where each item of data is twelve columns wide (so it is easy to extract data items using slicing) Name Joe Mary Dion Kayla Jose Sofia Erik Sara Height (m)Weight (kg) 1.82 1.60 1.90 1.72 1.78 1.63 1.98 1.57 72.57 63.50 90.71 66.31 70.23 65.12 92.21 65.77 Your task is read the file data.txt and calculate the max, min, and average of the height and weight columns and to add an additional column that has the BMI calculated based on each height and weight. Your output will look like this (and needs to be formatted like this). To match the testing on Mimir here ?s the format string: " {:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!