Question: python 1) (25 points) Write a program to print out the averages of information like that in the following two dimensional data table, which you
1) (25 points) Write a program to print out the averages of information like that in the following two dimensional data table, which you may assume has been read in by another earlier part of the program: categories = ["name", "height", "weight", "age ", "income "] data [ ["James Smith", 70.5, 160, 45, 67575] "Jacob Ertington", 68, 148, 31, 89600], ["Nancy Chu", 62.25, 125, 22, 58200], ["Theresa Fenner", 64, 135, 28, 77333) ["John Adams", 73, 170, 62, 123650] The goal is to print the averages for the categories in the categories list except the first, which will always be a person's name, for each of the lines in the two dimensional table in the data list. Each element of this data s s another list, with an entry corresponding to each category in the categories list. So for the above data, the output should look like: height 67.55 weight 147.60 age income 83271.60 37.60 Note that the averages should be printed with two decimal places. Also note that the data given here is only an example; the program should work for any such data. For full credit, do not assume that there are exactly 5 categories, and data for exactly 5 people, but decide how many there are from the size of the categories and data lists. The data above is only an example, and the program should work for any such data. 2) (25 points) With the same kind of data and categories arrays as in problem 1) above, open an output file, write the data into that file, and close it. For each person, first write a line with just that person's name, and then for each category except the "name", write a line with that category title, and that person's data for that category. After those data lines, write a blank line before the next person's data. (The last blank line is optional.) All the data values should be written with two decimal places, even though some of the data may be originally in integer form. Thus, if the data is as in problem1), the output should start with the lines: James Smith height 70.50 weight 160.00 age 45.00 income 67575.00 Jacob Ertington height 68.00 weight 148.00 age income 89600.00 31.00 Nancy Chu height 62.25 weight 125.00 age income 58200.00 22.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
