Computers and Technology

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) 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 Mirmir here is the format string: The formula for BMI is simple in the metric system:BMI = weight/height ** 2 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. 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 line-use 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. The second task is to w-rite that output to a file. The steps are 1. Open a file for writing, e. g. out file = 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) Close the file, e. g. outfile. 3. close () If you forget this step, nothing will be written to the file. Also, dont forget the parentheses.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 21:40, jeovontamarley
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
image
Computers and Technology, 24.06.2019 08:30, colebuug9
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
image
Computers and Technology, 24.06.2019 16:00, kamo90
How are roger williams, james oglethorpe, and william penn similar?
Answers: 3
image
Computers and Technology, 24.06.2019 18:20, seema12
7. design a circuit with three inputs (x, y, and z) representing the bits in a binary number, and three outputs (a, b, and c) also representing bits in a binary number. when the input is 1, 2, or 3, the binary output should be one lesser than the input. when the input is 4, 5, or 6, the binary output should be one greater than the input. when the input is 0, the output is 0, and when the input is 7, the output is 7. show your truth table, all computations for simplification, and the final circuit.
Answers: 2
Do you know the correct answer?
Given a data file, find the max, min, and average values of columns. Also, create an addition column...

Questions in other subjects: