Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, I am stuck on how to get the 1 st option going on here. I am not 100 % sure I have my data
Hi, I am stuck on how to get the 1st option going on here. I am not 100% sure I have my data formated correctly. I do know I need to "Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower" Here is my assiment information Python command line menu-driven application that allows a user to display, sort and update, as needed a List of U.S states containing the state capital, overall state population, and state flower. The Internet provides multiple references with these lists. For example: https://www.crestcapital.com/tax/us_states_and_capitals https://statesymbolsusa.org/categories/flower https://worldpopulationreview.com/states/state-capitals/ You will need to embed the State data into your Python code in a data structure of your choice, from the readings this week. The user interface will allow the user to perform the following functions: 1. Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower 2. Search for a specific state and display the appropriate Capital name, State Population, and an image of the associated State Flower. 3. Provide a Bar graph of the top 5 populated States showing their overall population. 4. Update the overall state population for a specific state. 5. Exit the program As before, generate an appropriate Welcome, prompt, and exit messages to help the user navigate the program. The program should continue to allow selections until the program is exited. 2 If a state is not found an appropriate message should be displayed. Hints: 1. Use the List data structure and associated sort() and searching capabilities 2. Create and use functions as often as possible. 3. Validate input data to ensure each entry from the user is correct before proceeding. 4. Prompt the user to reenter information as needed. 5. The following Python sites are excellent resources for learning more about the Python libraries mentioned in the readings that you should use as part of this exercise. a. https://matplotlib.org/tutorials/introductory/pyplot.html b. https://matplotlib.org/tutorials/introductory/images.html#sphx-glr-tutorialsintroductory- images-py 6. Use comments to document your code 7. Test with many combinations. 8. Use pylint to verify the code style - the goal is a 10! 9. Before you import a third part library (e.g. matplotlib) )you must install it. To install a Third Party My code sofar: """" Author: Michael Duncan Class: SDEV 300 6380 Building Secure Python Applications (2208 ), Date: 4 Sep 2020 Description: """"" # Capital, population and Flowers import sys def state_list (): # Return list of states pass def display_sorted_states(state_list): # toString # Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower print ( "State ", " Capital ", " Population ", " Flower " ), print(stateString(0), " ", stateString(1), " ", stateString(2)," ", stateString (3)) pass def search_state_display(state): print ( "State ", " Capital ", " Population ", " Flower " ), print ( stateString ( 0 ), " ", stateString ( 1 ), " ", stateString ( 2 ), " ", stateString ( 3 ), ), print ( state ( 0 ), " ", state ( 1 ), " ", state ( 2 ), " ", state ( 3 ), ), pass def display_bar_graph_top5(): # Bar graph of the top 5 populated States showing their overall population pass def update_population_for_State(state): # Update the overall state population for a specific state. pass def state_population(state): population = state.stateString(2), pass states = [ ('Alabama', 'Montgomery', 4903185, 'Camellia'), ('Alaska', 'Juneau', 731545, 'Forget-Me-Not'), ('Arizona', 'Phoenix', 7278717, 'Suguaro Catus Blossom'), ('Arkansas', 'Little Rock', 3017825, 'Apple Blossom'), ('California', 'Sacremento ', 39512223, 'Golden Poppy '), ('Colorado', 'Denver ', 5758736, 'Mountain Columbine '), ('Connecticut', 'Hatford ', 3565287, 'Mountain Laurel '), ('Delaware', 'Dover ', 973764, 'Peach Blossom '), ('Florida', 'Tallahassee ', 21477737, 'Orange Blossom '), ('Georgia ', 'Atlanta ', 10617423, 'Cherokee Rose '), ('Hawaii ', 'Honolulu ', 415872, 'Red Hibiscus '), ('Idaho ', 'Boise ', 1787065, 'Syringa '), ('Illinois ', 'Springfield ', 12671821, 'Violet '), ('Indiana ', 'Indianaplois ', 6732219, 'Peony '), ('Iowa ', 'Des Moines ', 3155070, 'Wild Rose '), ('Kansas ', 'Topeka ', 2913314, 'Sunflower '), ('Kentucky ', 'Frankfort ', 4467673, 'Goldenrod '), ('Louisiana ', 'Baton Rouge ', 4648794, 'Magnolia '), ('Maine ', 'Augusta ', 1344212, 'Pine Cone & Tassel '), ('Tennessee ', 'Nashville ', 6833174, 'Iris '), ('Maryland ', 'Annapolis, ', 6045680, 'Black-eyed Susan '), ('Deleware ', 'Dover ', 973764, 'Peach Blossom '), ('Massachusettes ', 'Boston ', 6949503, 'Mayflower '), ('Rhode_Island ', 'Providence ', 1059361, 'Violet '), ('Minniesota ', 'St.Paul ', 5639632, 'Lady-Slipper '), ('Mississippi ', 'Jackson ', 2976149, 'Magnolia '), ('Missouri ', 'Jefferson City ', 6137428, 'Hawthorne '), ('Michigan ', 'Lansing ', 9986857, 'Apple Blossom '), ('Montana ', 'Helena ', 1068778, 'Bitterroot '), ('Nebraska ', 'Lincoln ', 1934408, 'Goldenrod '), ('Nevada ', 'Carson City ', 3080156, 'Sagebrush '), ('New_Hampshire ', 'Concord ', 1359711, 'Purple Lilac '), ('Vermont ', 'Montpelier ', 623989, 'Red Clover '), ('New_Jersey ', 'Trenton ', 8882190, 'Violet '), ('New_Mexico ', 'Santa Fe ', 2096829, 'Yucca '), ('New_York ', 'Albany ', 19453561, 'Rose '), ('North_Carolina ', 'Raleigh ', 10488084, 'Flowering Dogwood '), ('Wyoming ', 'Cheyenne ', 78759, 'Indian Paintbrush '), ('North_Dakota ', 'Bismark ', 762062, 'Prairie Rose '), ('Ohio ', 'Columbus ', 11689100, 'Scalet Carnation '), ('Oklahoma ', 'Oklahoma City ', 3956971, 'Mistletoe '), ('Oregon ', 'Salem ', 4217737, 'Oregon Grape '), ('Pennsylvania ', 'Harrisburg ', 12801989, 'Mountain Laurel '), ('South_Carolina ', 'Columbia ', 5148714, 'Yellow Jessamine '), ('South_Dakota ', 'Pierre ', 88465, 'Pasque flower '), ('Texas ', 'Austin ', 28995881, 'Bluebonnet '), ('Utah ', 'Salt Lake City ', 3202985, 'Sego Lily '), ('Virginia ', 'Richmond ', 8535519, 'Dogwood '), ('Washington ', 'Olympia ', 7614893, 'Coast Rhododendron '), ('West_Virginia ', 'Charleston ', 1792147, 'Rhododendron '), ('Wisconsin ', 'Madison ', 5822434, 'Wood Violet ') ] user_input = 1 while True: print ( ' 1. Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower ' ), print ( '2. Search for a specific state and display the appropriate Capital name, State Population, and an image of ' 'the associated State Flower. ' ), print ( '3. Provide a Bar graph of the top 5 populated States showing their overall population ' ), print ( '4. Update the overall state population for a specific state. ' ), print ( '5. Exit the program ' ), user_input = int ( input ( ' Enter choices : ' ) ) # add check for int between 1 and 5 else message and return to menu # if user_input ( 0> or 5< ), then if user_input == 1: # Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower display_sorted_states ( state_list ) elif user_input == 2: # Search for a specific state and display the appropriate Capital name, State Population, and an image of the # associated State Flower. state_name = input ( 'Input your State: ' ).lower (), # using this would be cool us.states.STATES to check for valid state name search_state_display ( state_name ) elif user_input == 3: # Bar graph of the top 5 populated States showing their overall population # elif (user_input == 4 ): # Update the overall state population for a specific state. state_name = input ( ' Enter State Name: ' ) bird_name = input ( ' Enter State population: ' ) update_population_for_State ( state_name ) elif user_input == 5: # Exit the program sys.exit ()
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