02 Prove : Assignment
Overview
This assignment will give you practice using Python to read from files and process information.
Instructions
Write a Python 3 program to read from a .csv file containing rates from power companies. Your program should determine the average commercial rate, and also display the information for the highest and lowest rates found.
The data file you will use is freely available from data.gov, however a slightly cleaned-up version of it has been prepared and is available below (please use that one). It lists the commercial (comm_rate), industrial (ind_rate), and residential (res_rate) rates for each zip code.
Your program should do the following:
Prompt the user for a filename.
Open the requested file and read through it line by line.
Ignore the first line, as it contains header information.
Find the column for comm_rate and keep track of it as needed. (You may assume the file will have a consistent ordering of columns.)
After parsing through the complete file, display the average (mean) commercial rate across all zip codes.
Display the utility company, zip code, state, and rate for the zip code with the highest commercial rate in the file.
Display the utility company, zip code, state, and rate for the zip code with the lowest commercial rate in the file.
If there is a tie for the highest or lowest rate, you should display the zip code that came first in the file.
To help you in your development efforts, two versions of the data set will be provided:
/home/cs241/assign02/rates_small.csv
/home/cs241/assign02/rates.csv
Design
Your program should demonstrate good style and design principles. For example, you should break up the task into good, meaningful functions, use good variable names, and document your code with comments and function headers.
Sample Output
The following is an example of the output that should be generated:
Please enter the data file: /home/cs241/assign02/rates.csv
The average commercial rate is: 0.08402623352821378
The highest rate is:
Napakiak Ircinraq Power Co (99634, AK) - $0.839779005525
The lowest rate is:
Sierra Pacific Power Co (89496, NV) - $0.0
Automatic Grading Script (TestBed)
To assist you in your development, an automated test script is provided. Please keep in mind, that unlike checkpoints, your program will also be evaluated for code quality and correctness.
testBed cs241/assign02 assign02.py
Please keep in mind that it would be easy to "hard-code" your program to produce the output above, without actually looking in the file at all. This is obviously not what is expected for this assignment. Your program should be able to handle different files with different data as well.
Submission
Submit your program by logging into the CS Department Linux system, and running the submit command with your filename. Example (assuming my file is named "myAssign02.py":
submit myAssign02.py
You should then select the appropriate course (CS 241), instructor, and assignment from the list.
Assessment and Grading
For your information, the instructor will use these assessment guidelines to evaluate your assignment. Feel free to refer to this to understand the expectations of this submission.