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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:30, Nicki3729
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
image
Computers and Technology, 22.06.2019 08:30, marialuizavalen
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, Cocco
You have been supporting csm tech publishing's windows server 2016 server network for over a year. the office has two windows server 2016 servers running active directory and a number of other roles. management has informed you that a small sales office is opening in the same building three floors up. the sales manager wants to install a sales application on a server located in the sales office. this server will have limited physical security because there's no special room dedicated for it, which means it will be accessible to non-it personnel and visitors. you're considering installing windows server 2016 server core on the new server because accessing its console regularly probably won't be necessary, and this server will be managed from one of the other csm tech publishing servers. what are the benefits and drawbacks of using server core for this branch office? what are some things you should do to set up this server management environment?
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, batmandillon21
1. for which of the following are you not required to signal beforehand? a. changing lanes b. speeding up c. stopping
Answers: 2
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 in other subjects:

Konu
Mathematics, 24.12.2020 21:00
Konu
Mathematics, 24.12.2020 21:00
Konu
Chemistry, 24.12.2020 21:00
Konu
Mathematics, 24.12.2020 21:00