1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tensa zangetsu [6.8K]
3 years ago
15

g 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 Read in a list of states from a 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 ... Objectives Write the following in main.py: Open the states.txt file. Create a list called ‘states’ 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. For example, Alabama Alaska Arizona ... Note: You will lose points if you do not correctly work with the file. If you decide to just use a print statement to display the output, without using file input, and pass the test case with 100%, you will eventually lose points. This program will be checked after the deadline. In short, do not try to cheat the system by simply displaying the list of states.
Computers and Technology
1 answer:
mixas84 [53]3 years ago
3 0

Answer:

Check the explanation

Explanation:

# Step 1

the first thing to execute will be......

f = open("states.txt")

# Step 2

the second step is......

states = []

for line in f:

   states.append(line.strip())

# Step 3:

the third step is to......

for state in sorted(states):

   print(state)

f.close()

You might be interested in
Computers and Technology:
Monica [59]

Answer:

The algorithm:

Input days

sum = 0

for i = 1 to days

   input text

   sum = sum + text

end for

average = sum/days

print average

The program in pascal:

var days, sum, text, i:integer;

var average : real;

Begin

    write ('Days: '); readln(days);

    sum:=0;

    for i := 1 to days do begin

         write ('Text: ');  readln(text);  

         sum:=sum+text;

    end;

    average := (sum/days);

    writeln ('The average text is' , average);

End.

Explanation:

This declares all variables

var days, sum, text, i:integer;

var average : real;

This begins the program

Begin

This gets the number of days from the user

    write ('Days: '); readln(days);

Initialize sum to 0

    sum:=0;

This iterates through the days

    for i := 1 to days do begin

This gets the text for each day

         write ('Text: ');   readln(text);  

This sums up the texts

         sum:=sum+text;

End loop

    end;

Calculate average

    average := (sum/days);

Print average

    writeln ('The average text is' , average);

End program

End.

3 0
3 years ago
Why might a business choose a server-based network over a peer-to-peer network?
valina [46]

Answer:

Hope this helps you out    Answer: Greater security

Explanation:

Server maintains better relationship with server at everry time. So it gives maximum of security and reliability against unauthorised access

3 0
3 years ago
During which geologic era was nearly all of Earth's land concentrated into one giant mass called Pangaea?
Scorpion4ik [409]
The answer would be Mesozoic.
HOPE THIS HELPS YOU! ^_^
6 0
3 years ago
Harold wants to create a design that would depict the innocent and evil sides of human nature. Which colors can Harold use to de
belka [17]

Answer:

Usually good and evil are depicted as black and white or red and white. White being good, or pure.

Explanation:

8 0
3 years ago
Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
-Dominant- [34]

Answer:

User Interface

Explanation:

3 0
3 years ago
Other questions:
  • The number of bits used to store color information about each pixel is called ____.
    13·1 answer
  • What do you do to add a line or circle to your presentation?
    7·2 answers
  • 1. What does a computer
    7·2 answers
  • If i keep giving out brainlyest will i get banned again?
    12·2 answers
  • NEED HELP ASAP
    13·2 answers
  • What science category includes physics and biology?
    14·1 answer
  • What maintains data about various types of objects, events, people, and places?
    10·1 answer
  • 25 points
    8·2 answers
  • How are the waterfall and agile methods of software development similar?
    13·1 answer
  • What is the greatest number of bits you could borrow from the host portion of a class B subnet mask and still have at least 130
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!