Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, ahmedislife
Alocal reaction will occur at the site of the exposure such as irritation or damage to the skin eye or local reaction will occur at the site of the exposure such as irritation or damage to the skin ireland lounges
Answers: 3
image
Computers and Technology, 24.06.2019 01:00, cheycheybabygirl01
How can the temperature of a room be raised by 5degreesf?
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, summerjoiner
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, live4dramaoy0yf9
Explain the importance of html in web page designing in 20 sentences..
Answers: 1
Do you know the correct 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: