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
To annotate a document with a remark for another reviewer to address, select the _____ feature. comments track changes annotatio
kupik [55]
Select the comments feature.

We use comments in our documents to track issues for follow up or make suggestions to other people. A comment is inserted inside a balloon or a box that appears in the document's margins. Whatever the situation you may be in, you can easily add comments in a word document.

 



6 0
3 years ago
Read 2 more answers
What is the difference between the ISO and the OSI?
geniusboy [140]

ISO it is an organzation for agreement on internationational of network communication worldwide

OSI is the model for understanding and designing a network architecture

7 0
3 years ago
Read 2 more answers
Write a program that selects a random number between 1 and 5 and asks the user to guess the number. Display a message that indic
anzhelika [568]

Answer:

Following is given the program code as required:

Explanation:

  • Initially a class is created name RandomGuessMatch.java
  • An instance for scanner class is created in main method.
  • Now the upper and lower bounds for guess are given by variables MIN (1) and MAX(5).
  • Now user will be allowed to guess the number.
  • The difference between the guessed number and actual number is calculated.
  • This will tell the compiler weather to print correct or incorrect.

<h2>i hope it will help you!</h2>

5 0
3 years ago
What will happen if more than 2 devices attempt to access the internet ?
Lemur [1.5K]
Well it depends what kind of Internet u have
5 0
3 years ago
To make an exact copy of an existing slide, from the new slide gallery
Anuta_ua [19.1K]
If you're talking about Microsoft PowerPoint, just go to the slide view, right click and click "Duplicate Slide".

I'm sure you can also Copy and Paste slides. 
3 0
3 years ago
Other questions:
  • What action makes RAM on your computer disappear?
    12·2 answers
  • . String literals are surrounded by _____ quotes
    14·1 answer
  • Which of the following STEM discoverers developed a new type of computer hardware?
    11·1 answer
  • Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop
    12·1 answer
  • Create a database with information about products in a catalog. As you plan, keep in mind that later you will want to sort this
    10·2 answers
  • What is Sleep mode? Check all of the boxes that apply.
    12·1 answer
  • What explains the discrepancy between the number of bytes you can
    13·1 answer
  • These days, a digital signature is just as legitimate and trusted as an old-fashioned John Hancock on paper.
    9·1 answer
  • You are going to visit a national park, and have never been there before. You are using a map to try and make the distance trave
    11·1 answer
  • Which of the following are exclusively associated with copyright protection
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!