Question: I keep getting an error and it will not keep getting the following message, I don't understand why: File C:/Users/mike/Documents/Lab3.py/State-pop.py, line 13 state(1) = ('Alabama',

I keep getting an error and it will not

keep getting the following message, I don't understand why:

File "C:/Users/mike/Documents/Lab3.py/State-pop.py", line 13

state(1) = ('Alabama', 'Montgomery', 4903185, 'Camellia')

^

SyntaxError: cannot assign to function call

Process finished with exit code 1:

Here is my assignment:

The first exercise produces a command line menu-driven python application providing users with the ability to search and display U.S. State Capital, population and Flowers. The second part documents your testing and pylint analysis results.

1. (80 points) 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. 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

library, you use this command at the command prompt:

python -m pip install -U matplotlib

2. (20 points) Document your testing results using your programming environment. You should also

include and discuss your pylint results for the application. The test document should include a test

table that includes the input values, the expected results and the actual results. A screen capture

should be included that shows the actual test results of running each test case found in the test

table. Be sure to include multiple test cases to provide full coverage for all code and for each

function you develop and test.

I keep getting the following message, I don't understand why:

File "C:/Users/mike/Documents/Lab3.py/State-pop.py", line 13

state(1) = ('Alabama', 'Montgomery', 4903185, 'Camellia')

^

SyntaxError: cannot assign to function call

Process finished with exit code 1

****************************************************************

My code:

""""

Author: Michael Duncan

Class: SDEV 300 6380 Building Secure Python Applications (2208 ),

Date: 4 Sep 2020

Description:

"""""

# Capital, population and Flowers

import sys

state(1) = ('Alabama', 'Montgomery', 4903185, 'Camellia')

state(2) = ('Alaska', 'Juneau', 731545, 'Forget-Me-Not')

state(3) = ('Arizona', 'Phoenix', 7278717, 'Suguaro Catus Blossom')

state(4) = ('Arkansas', 'Little Rock', 3017825, 'Apple Blossom')

state(5) = ('California', 'Sacremento ', 39512223, 'Golden Poppy ')

state(6) = ('Colorado', 'Denver ', 5758736, 'Mountain Columbine ')

state(7) = ('Connecticut', 'Hatford ', 3565287, 'Mountain Laurel ')

state(8) = ('Delaware', 'Dover ', 973764, 'Peach Blossom ')

state(9) = ('Florida', 'Tallahassee ', 21477737, 'Orange Blossom ' )

state(10)= ('Georgia', 'Atlanta ', 10617423, 'Cherokee Rose ' )

state(11)= ('Hawaii', 'Honolulu ', 415872, 'Red Hibiscus ' )

state(12)= ('Idaho', 'Boise ', 1787065, 'Syringa ' )

state(13)= ('Illinois', 'Springfield ', 12671821, 'Violet ' )

state(14)= ('Indiana', 'Indianaplois ', 6732219, 'Peony ' )

state(15)= ('Iowa', 'Des Moines ', 3155070, 'Wild Rose ' )

state(16)= ('Kansas', 'Topeka ', 2913314, 'Sunflower ' )

state(17)= ('Kentucky', 'Frankfort ', 4467673, 'Goldenrod ' )

state(18)= ('Louisiana', 'Baton Rouge ', 4648794, 'Magnolia ' )

state(19)= ('Maine', 'Augusta ', 1344212, 'Pine Cone & Tassel ' )

state(20)= ('Tennessee', 'Nashville ', 6833174, 'Iris ' )

state(21)= ('Maryland', 'Annapolis,', 6045680, 'Black-eyed Susan ' )

state(22)= ('Deleware', 'Dover ', 973764, 'Peach Blossom ' )

state(23)= ('Massachusettes', 'Boston ', 6949503, 'Mayflower ' )

state(24)= ('Rhode_Island', 'Providence ', 1059361, 'Violet ' )

state(25)= ('Minniesota', 'St.Paul ', 5639632, 'Lady-Slipper ' )

state(26)= ('Mississippi', 'Jackson ', 2976149, 'Magnolia ' )

state(27)= ('Missouri', 'Jefferson City ', 6137428, 'Hawthorne ' )

state(28)= ('Michigan', 'Lansing ', 9986857, 'Apple Blossom ' )

state(29)= ('Montana', 'Helena ', 1068778, 'Bitterroot ' )

state(30)= ('Nebraska', 'Lincoln ', 1934408, 'Goldenrod ' )

state(31)= ('Nevada', 'Carson City ', 3080156, 'Sagebrush ' )

state(32)= ('New_Hampshire', 'Concord ', 1359711, 'Purple Lilac ' )

state(33)= ('Vermont', 'Montpelier ', 623989, 'Red Clover ' )

state(34)= ('New_Jersey', 'Trenton ', 8882190, 'Violet ' )

state(35)= ('New_Mexico', 'Santa Fe ', 2096829, 'Yucca ' )

state(36)= ('New_York', 'Albany ', 19453561, 'Rose ' )

state(37)= ('North_Carolina', 'Raleigh ', 10488084, 'Flowering Dogwood ' )

state(38)= ('Wyoming', 'Cheyenne ', 78759, 'Indian Paintbrush ' )

state(39)= ('North_Dakota', 'Bismark ', 762062, 'Prairie Rose ' )

state(40)= ('Ohio', 'Columbus ', 11689100, 'Scalet Carnation ' )

state(41)= ('Oklahoma', 'Oklahoma City ', 3956971, 'Mistletoe ' )

state(42)= ('Oregon', 'Salem ', 4217737, 'Oregon Grape ' )

state(43)= ('Pennsylvania', 'Harrisburg ', 12801989, 'Mountain Laurel ' )

state(44)= ('South_Carolina', 'Columbia ', 5148714, 'Yellow Jessamine ' )

state(45)= ('South_Dakota', 'Pierre ', 88465, 'Pasque flower ' )

state(46)= ('Texas', 'Austin ', 28995881, 'Bluebonnet ' )

state(47)= ('Utah', 'Salt Lake City ', 3202985, 'Sego Lily ' )

state(48)= ('Virginia', 'Richmond ', 8535519, 'Dogwood ' )

state(49)= ('Washington', 'Olympia ', 7614893, 'Coast Rhododendron ' )

state(50)= ('West_Virginia', 'Charleston ', 1792147, 'Rhododendron ' )

state(51)= ('Wisconsin', 'Madison ', 5822434, 'Wood Violet ')

def state_list ():

# Return list of states

pass

def display_sorted_states():

# toString

# Display all U.S. States in Alphabetical order along with the Capital, State Population, and Flower

state_count: int = 1

if(state_count <= 51):

print (state(state_count))

state_count = state_count + 1

#state_list.sort()

#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

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 ()

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!