Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Download the file markets.txt which contains geographic information for over 7000 farmers markets in the US (source http://explore.data.gov/d/wfna-38eyLinks to an external site.). Each line contains

Download the file markets.txt image text in transcribedwhich contains geographic information for over 7000 farmers markets in the US (source http://explore.data.gov/d/wfna-38eyLinks to an external site.). Each line contains information about a one farmers market. Data fields are separated by a single "#" symbol. The fields are (in this order): state, market name, street address, city, zip code.

Download the skeleton code problem2.pyimage text in transcribed.

a) Write a class Market that represents a farmers market. The Market class should have the following attributes:

state (a string)

market_name (a string)

street_address (a string)

zip code (an int)

city (a string)

You can ignore the longitude and latitude entries.

b) Add a __str__ method that returns information about the famers market in human readable form (use string formatting). For example

Columbia University Greenmarket E. Side of Broadway between 114th & 115th Streets New York, New York 10027

c) Write a function read_markets(filename), that reads in the market data from a file. The function should return a dictionary mapping zip codes to lists of Market objects (there can be multiple markets in the same zip code).

d) Write a main program that first calls read_markets to read in markets.txt. Then, your program should prompt the user to type in a zip code. It should then print out the string representation for each market in that zip code, or "No farmers markets in your zip code." if none were found.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago