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
What refrigerant has been approved for new household refrigerators and freezers
Alexxx [7]
Bsbsnsnsnsn jajwjemoeododhdhdw whajsjshtzzvsssnxbba. 3
8 0
3 years ago
Alguien porfavor me dice como cambiar de idioma en brainly
Kitty [74]

Answer:

Creo que necesitas crear una nueva cuenta en el Brainly español. Para encontrarlo, tal vez pueda buscar una pregunta aleatoria en Internet seguida de Brainly y, con suerte, encontrará la correcta. Luego crea una cuenta en ese Brainly. Al menos pienso cómo lo haces.

5 0
2 years ago
What command would you use to copy the content of a file named report1 to another called report1uc. Convert the content of repor
Ray Of Light [21]

Answer:

Answered below.

Explanation:

This answer is applicable to Linux.

There are several commands for copying files in Linux. cp and rsync are the most widely used. cp though, is the command used to copy files and their contents.

To copy a file named report1.txt to another file named report1uc.txt in the current directory, the following command is run.

$ cp report1.txt report1uc.txt

You can change the case of the strings in the file by using the tr command.

tr [:lower:] [:upper:]

For example,

$ echo brainly | tr [:lower:]. [:upper:]

Result is BRAINLY.

7 0
3 years ago
What are the primary functions of motor oil? a. Reduce friction and prevent wear b. Keep engine surfaces clean c. Remove heat to
ryzh [129]

The answer is E: all of the above.

7 0
3 years ago
Write two sentences but each one having either computer in it or technology in it. You can use a word more than once in a senten
Ksju [112]

Answer:

Sentences:

1.My computer has a virus

2.Technology may take over the world someday

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • What is the easiest way to be sure you have selected all of the content related to a specific tag?
    11·1 answer
  • Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
    7·1 answer
  • Take some time to do some research about small businesses in your area. Select one and using HTML design a simple site that educ
    11·1 answer
  • Suppose you have one particular application that is trying to send data on the Internet but none of the data is making it to the
    15·2 answers
  • The CSS property of top , bottom , left , or right moves the element the specified distance from the respective edge of the clos
    7·1 answer
  • According to the text, the three IT trends that are having the greatest impact on the IT environment are:
    11·1 answer
  • A motorist is using the AHP to choose a new car from three possible models Arrow, a Bestmobile and a Commuter. The choice will a
    15·2 answers
  • Why computer literacy is vital to access in business work
    7·1 answer
  • Why are Quick Parts useful in an Outlook message?
    5·1 answer
  • Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit f
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!