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
Dmitrij [34]
3 years ago
14

Create a program that reads words.txt (link near top of our home page) in order to: determine the length of the longest word(s)

and output that length plus the first word of this length found. determine the length of the shortest word(s) and output that length plus the first word of this length found determine and output the average length of all the words in the list.
Computers and Technology
1 answer:
Alexeev081 [22]3 years ago
3 0
# In Python 3
# https://pastebin.com/fPSmmE5w

longest = [""]
shortest = None


with open("words.txt") as words:
   for line in words.readlines():
       for word in line.split():
           if len(word) > len(longest[0]):
               longest = [word]
           elif len(word) == len(longest[0]):
               longest.append(word)
           elif shortest is None or len(word) < len(shortest[0]):
               shortest = [word]
           elif len(word) == len(shortest[0]):
               shortest.append(word)


def format_printable(words):
   return ["{}: {}".format(len(word), word) for word in words]


print(
   "Longest:\n",
   "\n".join(format_printable(longest)),
   "\nShortest:\n",
   "\n".join(format_printable(shortest)),
)
You might be interested in
ORANGE COLORED SIGNS AND FLAGS MEAN THAT YOU MUST BE ALERT FOR:
Finger [1]
The best answer is B
Orange typically signalizes road work or construction.
4 0
4 years ago
Read 2 more answers
A file can be safed with a different file name then it currently has by clicking on save ? in the file tab
Mazyrski [523]

Answer:

Click the File tab. Click Save As. Choose a file location, such as OneDrive or This PC to store your file.

Explanation:

click the File tab. Click Save As. Choose a file location, such as OneDrive or This PC to store your file. In the File name box, enter a new name for the file. In the Save as type list, click the file

5 0
2 years ago
The methods of the Character class that begin with ____ return a character that has been converted to the stated format.
Pavel [41]

Answer:

most probably the answer is 'to'

6 0
3 years ago
Which of the following is an example of a database?
Katyanochek1 [597]
I think it’s A or D hope that helps
6 0
3 years ago
Read 2 more answers
The major computer operations include what?
Goryan [66]

Answer:

The major computer operations include sequence and looping. ... Visual Basic, C++, and Java are all examples of computer programming languages.

7 0
3 years ago
Other questions:
  • Which type of security personnel may work for government as well as for private security agencies?
    7·2 answers
  • What possible effects could cyber attack have on Johannesburg stock exchange
    6·1 answer
  • 30 POINTS!!!
    9·2 answers
  • True or false there is no relationship between the purpose of the page and the page quality
    13·1 answer
  • Which of the following statements is false? The ARPANET is the precursor to today’s Internet. Today’s fastest Internet speeds ar
    11·1 answer
  • The smallest unit of storage is​
    15·1 answer
  • In the Sender Message Channel Receiver (SMCR) model, the ______ is the large, bureaucratic organization that produces messages.
    5·1 answer
  • In a database, it is possible to make changes such as font, text style, text color, line color, and background color. true false
    13·2 answers
  • See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will pri
    6·1 answer
  • A cell's address, its position in the workbook, is referred to as a ________________ when it is used in a formula.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!