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 07:00
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
question
Computers and Technology, 23.06.2019 08:30
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
question
Computers and Technology, 23.06.2019 22:50
An environmental protection agency study of 12 automobiles revealed a correlation of 0.47 between engine size and emissions. at 0.01 significance level, can we conclude that there is a positive association between the variables? what is the p value? interpret.
Answers: 2
question
Computers and Technology, 24.06.2019 08:30
Formatting rows and columns is similar to cell formatting. in an openoffice calc spreadsheet, you can format data entered into rows and columns with the of the rows and columns options. you can insert rows and columns into, or delete rows and columns from, a spreadsheet. use the insert or delete rows and columns option on the insert tab. alternatively, select the row or column where you want new rows or columns to appear, right-click, and select insert only row or only column options. you can hide or show rows and columns in a spreadsheet. use the hide or show option on the format tab. for example, to hide a row, first select the row, then choose the insert tab, then select the row option, and then select hide. alternatively, you can select the row or columns, right-click, and select the hide or show option. you can adjust the height of rows and width of columns. select row and then select the height option on the format tab. similarly, select column, then select the width option on the format tab. alternatively, you can hold the mouse on the row and column divider, and drag the double arrow to the position. you can also use the autofit option on the table tab to resize rows and columns.
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
Questions on the website: 13722367