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, 22.06.2019 15:00
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
Answers: 2
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
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, 20.04.2021 17:10
question
Mathematics, 20.04.2021 17:10
question
Mathematics, 20.04.2021 17:10
question
Mathematics, 20.04.2021 17:10
question
Mathematics, 20.04.2021 17:10
question
German, 20.04.2021 17:10
Questions on the website: 13722361