Use Python Write a questionanswering feature that enables a

Use Python. Write a question-answering feature that enables a user to name two states by two character abbreviations and answer the following question: Which state is has the bluest, greenest or reddest display color? I have written the entire code of the map of US states, so I can see the different colors for each state, but how would I make the comparisons? Any help will be appreciated!

Solution

import matplotlib.pyplot as plt

from mpl_toolkits.basemap import Basemap

from matplotlib.patches import polygon

map= Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,projection=\'lcc\', lat_1=33,lat_2=45, lon_0=-95)

map.readshapefile(\'st99_d00\', name=\'states\', drawbounds=True)

state_names = []

for shape_dict in map.states_info:

state_names.append(shape_dict[\'NAME\'])

ax = plt.gca()

seg = map.states[state_name.index(\'Texas\')]

poly = Polygon(seg,facecolor=\'red\', edgecolor=\'red\')

ax.asdd_patch(poly)

plt.show()

simailarly code is same for all the remaining staes, just change the code near state name \'Texas\' you will have red and so on for different states different colors

Use Python. Write a question-answering feature that enables a user to name two states by two character abbreviations and answer the following question: Which st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site