subject

Create a program that reads a list of states from an input file, puts them in order, and displays the sorted list to the user. Description
Prompt the user for the name of the text file, read in a list of states from the file, and output those states in alphabetical order.
Provided input files
A single input file named states. txt is provided that lists states of the United States - one state per row. Some states have lowercase letters, where some begin with uppercase letters. As a reminder, lowercase letters come after uppercase letters alphabetically. The states are in a random order. The file has the following format:
Michigan
california
New Mexico
Texas
nevada
...
Your program will sort the states in the file and display to the user (not a file) an alphabetized list of all the states, with one state per line. For example,
Alabama
Alaska
Arizona
California
...
Notice that you do not see arkansas in the above sample. In the provided text file, arkansas is spelled with a lowercase "a". Lowercase letters come after uppercase letters alphabetically.
Objectives
Remember your incremental development strategy. Start with the pseudocode:
Prompt the user for a text file
Open the file.
Create a list where each element in the list is one of the states read from the file. Do not change the text that is read from the file.
Print to the user (not to a file) an alphabetized list of all the states, with one state per line.
Implement the pseudocode incrementally. Consider the following phases:
Open the file and put the contents in a list. Display the list to verify populating the list was successful.
Sort the list. Display the sorted list to verify sorting was successful.
Display the sorted list, one state per line.
Remove all the extra print statements and test the program.
Hint: You may want to look up the helpful list method sort() and / or built in function sorted in the official Python docs
states. txt:
California
Texas
New York
Florida
lllinois
Pennsylvania
Ohio
Michigan
New Jersey
georgia
North Carolina
Virginia
Massachusetts
Indiana
Washington
tennessee
Missouri
Wisconsin
Maryland
Arizona
Minnesota
Louisiana
Alabama
Colorado
Kentucky
South Carolina
Oklahoma
Oregon
Connecticut
iowa
Mississippi
Kansas
arkansas
Utah
Nevada
West Virginia
New Mexico
Nebraska
maine
Idaho
New Hampshire
Hawaii
Rhode Island
Montana
Delaware
South Dakota
North Dakota
Alaska
Vermont
Wyoming

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 11:00
Describe three characteristics of at-risk drivers. a. b. c. describe three characteristics of safe drivers. a. b. c. describe three driver errors that could cause a collision. a. b. c. how will this information affect you as a driver now and in the future? (2-3 sentences)
Answers: 2
question
Computers and Technology, 24.06.2019 05:30
How do i get rid of my member ship for
Answers: 2
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
You know the right answer?
Create a program that reads a list of states from an input file, puts them in order, and displays th...
Questions
question
Mathematics, 21.04.2021 01:00
question
Health, 21.04.2021 01:00
question
Mathematics, 21.04.2021 01:00
question
Mathematics, 21.04.2021 01:00
question
Medicine, 21.04.2021 01:00
Questions on the website: 13722367