subject
Engineering, 05.05.2020 23:07 ocean11618

Guidelines • You are not allowed to import anything. We know about the csv module, but you may not use it. • You are not allowed to use anything we haven't learned so far, including but not limited to: list comprehension, lambda functions, generators, builtins like zip(), etc. From built-in functions, you are not allowed to call sum(). Everything else is fair game. • You are allowed to use sets, dictionaries, and any of their respective operations. • You are allowed to use any string operations, including any way to format strings, except for string. find(), and string. replace() You can use any list operation, except for list. count() and list. sort() Do not hard code. Assignment The energy files are in the "csv" format, short for "comma separated values." These are just plain text files to represent a spreadsheet of information, where each piece of data is separated by a comma. The first row of each file is a description of what each column of information represents. Apart from the first column, the format of the header data is "Consumption. Sector. Energy" where Sector and Energy are replaced by one of several possible strings seen below. The possible economic sectors are (note the spaces): "Commercial", "Electric Power", "Industrial", "Refinery", "Residential", and "Transportation." The possible energy types are (note the spaces): "Coal", "Distillate Fuel Oil", "Geothermal", "Hydropower", "Kerosene", "Liquefied Petroleum Gases", "Other Petroleum Products", "Natural Gas", "Solar, "Wind", "Wood" State files A single state file contains the information for all years for the state given by the file name. Each line is one year's worth of comma separated data. The first line of a state file (the header) looks like this: Year, Consumption commercial. Coal 1, Consumption. Transportation. Natural Gas The header row tells you what each number in a particular line represents. The first number in a line of data in the state file is a year that data represents. The next number is the consumption in the "Commercial" sector for the "Coal" energy type. The last number in the line is the consumption in the "Transportation" sector for the "Natural Gas" energy type. The same idea applies to rest of the columns. Year files A single year file contains the information for all states for the year given by the file name. Each line is one state's worth of comma separated data. The first line of a year file (the header) looks like this: State, Consumption Commercial. coal,... Consumption. Transportation. Natural Gas The header row tells you what each number in a particular line represents, just like the state file. Functions The examples that you see here use the files that you are given to accompany this assignment. Make sure that when you test you either use the filename with a correct relative path to the csv file you are testing or you move the file you are testing to be in the same folder as your program. def summarize(filename): Description: Create a new file that contains a summary of the total consumption for three sectors: "Residential," "Commercial," and "Industrial." The summary is a per-line total of the consumption for all energy types of each sector. For each of the three sectors, calculate the sum of that sector's consumption in each line of the file. Write that sum to an output file in the appropriate column. You should write your output to a file, whose name is based on the original filename by adding "_summary" to the name. For example, if the input filename is "maryland. csv" then the output file should be called "maryland_summary. csv" The resulting file should have lines that look something like this (different for year files, where the leftmost column would be the states): Year, Consumption. Commercial, Consumption. Industrial, Consumption. Residential 1994,6787234,78849,610734 Parameters: filename, the name of an energy data file as described earlier. Return value: None, instead your result should be written to a file. Example output files for the following are included in the zipped files for this assignment. summarize('new_york. csv') < output in 'new_york_summary. csv' summarize('1977.csv') → output in '1977_summary. csv' summarize('virginia. csv') → output in 'virginia_summary. csv'

ansver
Answers: 1

Another question on Engineering

question
Engineering, 04.07.2019 18:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
question
Engineering, 04.07.2019 18:20
Along 8-cm diameter steam pipe whose external surface temperature is 900c connects two buildings. the pipe is exposed to ambient air at 70c with a wind speed of 50 km/hr blowing across the pipe. determine the heat loss from the pipe per unit length. (b) air at 500c enters a section of a rectangular duct (15 cm x 20 cm) at an average velocity of 7 m/s. if the walls of the duct are maintained at 100c. a) the length of the tube for an exit temperature of the air to be 40 0c. b)the rate of heat transfer from the air. c) the fan power needed to overcome the pressure drop in this section of the duct.
Answers: 1
question
Engineering, 04.07.2019 19:20
Liquid flows at steady state at a rate of 2 lb/'s through a pump, which operates to raise the elevation of the liquid 100 ft from control volume inlet to exit. the liquid specific enthalpy at the inlet is 40.09 btu/lb and at the exit is 40.94 btub. the pump requires 3 btu/s of power to operate. if kinetic energy effects are negligible and gravitational acceleration is 32.174 tt/s, the heat transfer rate associated with this steady state process is most closely 1)-2,02 btu/s from the liquid to the surroundings 2)-3.98 btu/s from the surroundings to the liquid. 3)-4.96 btu/s from the surroundings to the liquid. 4)-1.04 btu/s from the liquid to the surroundings.
Answers: 2
question
Engineering, 04.07.2019 19:20
To design a steam turbine to produce 12,000 hp power. a engineer comsiders using a steady state stean low st 1160fr and engineer considers using a steady state steam flow at 1160°r and 450 psia to drive this steam turbine. the exhaust of the steam is cooled by the lake (vacuum). heat losing to the surroundings is measured at a rate of 555.55 btu/s. (a) sketch the system with the given conditions. (b) neglecting kinetic and potential energy changes from inlet to exit, determine the volumetric flow rate of the steam at the inlet, (ft'/hr). must clearly show unit conversions at crtical terms.
Answers: 1
You know the right answer?
Guidelines • You are not allowed to import anything. We know about the csv module, but you may not u...
Questions
question
Health, 18.08.2021 17:10
question
Mathematics, 18.08.2021 17:10
question
Mathematics, 18.08.2021 17:10