Python command line menu-driven application that allows a user to display, sort and update, a List of U.S states containing the state capital, if possible. Seeing what they looks like in a list.

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...
icon
Related questions
Question
100%

I need a Python command line menu-driven application that allows a user to display, sort and
update, a List of U.S states containing the state capital, if possible. Seeing what they looks like in a list.

Expert Solution
Step 1

# define an empty list which will carry all the data
state = []
# state.append inserts the contents to the list named state
state.append ( ['Alabama', 'Montgomery', 4903185, 'Camellia'] )
state.append ( ['Alaska', 'Juneau', 731545, 'Forget-Me-Not'] )
state.append ( ['Arizona', 'Phoenix', 7278717, 'Suguaro Catus Blossom'] )
state.append ( ['Arkansas', 'Little Rock', 3017825, 'Apple Blossom'] )
state.append ( ['California', 'Sacremento ', 39512223, 'Golden Poppy'] )
state.append ( ['Colorado', 'Denver', 5758736, 'Mountain Columbine'] )
state.append ( ['Connecticut', 'Hatford', 3565287, 'Mountain Laurel'] )
state.append ( ['Delaware', 'Dover', 973764, 'Peach Blossom'] )
state.append ( ['Florida', 'Tallahassee', 21477737, 'Orange Blossom'] )
state.append ( ['Georgia', 'Atlanta', 10617423, 'Cherokee Rose'] )
state.append ( ['Hawaii', 'Honolulu', 415872, 'Red Hibiscus'] )
state.append ( ['Idaho', 'Boise', 1787065, 'Syringa'] )
state.append ( ['Illinois', 'Springfield', 12671821, 'Violet'] )
state.append ( ['Indiana', 'Indianaplois', 6732219, 'Peony'] )
state.append ( ['Iowa', 'Des Moines', 3155070, 'Wild Rose'] )
state.append ( ['Kansas', 'Topeka', 2913314, 'Sunflower'] )
state.append ( ['Kentucky', 'Frankfort', 4467673, 'Goldenrod'] )
state.append ( ['Louisiana', 'Baton Rouge', 4648794, 'Magnolia'] )
state.append ( ['Maine', 'Augusta', 1344212, 'Pine Cone & Tassel'] )
state.append ( ['Tennessee', 'Nashville', 6833174, 'Iris'] )
state.append ( ['Maryland', 'Annapolis', 6045680, 'Black-eyed Susan'] )
state.append ( ['Deleware', 'Dover', 973764, 'Peach Blossom'] )
state.append ( ['Massachusettes', 'Boston', 6949503, 'Mayflower'] )
state.append ( ['Rhode Island', 'Providence', 1059361, 'Violet'] )
state.append ( ['Minniesota', 'St.Paul', 5639632, 'Lady-Slipper'] )
state.append ( ['Mississippi', 'Jackson', 2976149, 'Magnolia'] )
state.append ( ['Missouri', 'Jefferson City', 6137428, 'Hawthorne'] )
state.append ( ['Michigan', 'Lansing', 9986857, 'Apple Blossom'] )
state.append ( ['Montana', 'Helena', 1068778, 'Bitterroot'] )
state.append ( ['Nebraska', 'Lincoln', 1934408, 'Goldenrod'] )
state.append ( ['Nevada', 'Carson City', 3080156, 'Sagebrush'] )
state.append ( ['New Hampshire', 'Concord', 1359711, 'Purple Lilac'] )
state.append ( ['Vermont', 'Montpelier', 623989, 'Red Clover'] )
state.append ( ['New Jersey', 'Trenton', 8882190, 'Violet'] )
state.append ( ['New Mexico', 'Santa Fe', 2096829, 'Yucca'] )
state.append ( ['New York', 'Albany', 19453561, 'Rose'] )
state.append ( ['North Carolina', 'Raleigh', 10488084, 'Flowering Dogwood'] )
state.append ( ['Wyoming', 'Cheyenne', 78759, 'Indian Paintbrush'] )
state.append ( ['North Dakota', 'Bismark', 762062, 'Prairie Rose'] )
state.append ( ['Ohio', 'Columbus', 11689100, 'Scalet Carnation'] )
state.append ( ['Oklahoma', 'Oklahoma City', 3956971, 'Mistletoe'] )
state.append ( ['Oregon', 'Salem', 4217737, 'Oregon Grape'] )
state.append ( ['Pennsylvania', 'Harrisburg', 12801989, 'Mountain Laurel'] )
state.append ( ['South Carolina', 'Columbia', 5148714, 'Yellow Jessamine'] )
state.append ( ['South Dakota', 'Pierre', 88465, 'Pasque flower'] )
state.append ( ['Texas', 'Austin', 28995881, 'Bluebonnet'] )
state.append ( ['Utah', 'Salt Lake City', 3202985, 'Sego Lily'] )
state.append ( ['Virginia', 'Richmond', 8535519, 'Dogwood'] )
state.append ( ['Washington', 'Olympia', 7614893, 'Coast Rhododendron'] )
state.append ( ['West Virginia', 'Charleston', 1792147, 'Rhododendron'] )
state.append ( ['Wisconsin', 'Madison', 5822434, 'Wood Violet'] )

def display_sorted_states():
    print(state)

def sort_state():
    state.sort()

def update_population_for_State(name, population):
    for i in state:
        if i[0]==name:
            i[2]=population
            return
    print("State not found in database")

while True:
    print ( '1. Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower ' ),
    print ( '2. Sort the overall state population data. ' ),
    print ( '3. Update the overall state population for a specific state. ' ),
    print ( '4. 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_sorted_states ()

    elif user_input == 2:
        sort_state()
    
    elif user_input ==3:
        name = input("Enter state name: ")
        population = int(input("Enter current population: "))
        update_population_for_State(name, population)

    elif user_input == 4:
        # Exit the program
        print("Good Bye!!")
        sys.exit ()

    elif user_input >= 4:
        print('Please only enter a value between 1 and 5')

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY