Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US overnment showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code he data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers. our function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's alue should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1). mportant Hints: You will really, really want to use the built-in csv library because it makes processing a CSy file much easier and Area Name values may include commas.
Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US overnment showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code he data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers. our function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's alue should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1). mportant Hints: You will really, really want to use the built-in csv library because it makes processing a CSy file much easier and Area Name values may include commas.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question

Transcribed Image Text:Part B - reading CSV files
You will need a Python repl to solve part B.
Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US
government showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format
Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code
The data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers.
Your function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's
value should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1).
Important Hints:
* You will really, really want to use the built-in csv library because it makes processing a CSV file much easier and Area Name values may include commas.
* You should get the value the accumulator associates with a key, since the state code may be new. A good default value would be 1000000 since that will always be greater than an area's median rent for an
efficiency.)
Sample test cases:
cheapest_rent_per_state("empty.csv") would evaluate to { } (finds bug if accumulator variable not initialized correctly)
cheapest_rent_per_state("simple.csv") would evaluate to { 'CA' : 2103.0, 'NY' : 1665.0} (finds bug if accumulator variable not updated correctly)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY