Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Ask for two inputs: Ask for the name of the input file. Ask for the name of the output file that your code will produce.
- Ask for two inputs:
- Ask for the name of the input file.
- Ask for the name of the output file that your code will produce.
- Prints:
- Nothing
- Actions:
- Opens the input file
- Opens the output file
- Pulls off the header and adds one more column labeled "Density"
- For each territory provided in the data file you opened:
- extract population and size
- calculate population density (people per square area)
- writes the original data PLUS the population density into the output csv file
- Closes both files
- Data files to use:
- SmallData.csv
- StateData.csv
- CountryData.csv
- Example run of the program:
- Note: This means I need to be able to OPEN whatever file name I want. Do NOT hardcode "StateData.csv" into your open call. Instead, ask for a file name with input (say input_filename), and then open it in your program like this:
- fin = open(input_filename,"r")
- Example output using the StateData.csv input file:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started