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
Which unit of computer is used to processed data?​<br>Please help!!!!!!
RoseWind [281]

Hello There!

AnimeVines is here!

Is it Central Processing Unit?

HopeThisHelps!!

AnimeVines

7 0
3 years ago
Read 2 more answers
Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer j
Allushta [10]

Answer:

d. by increasing their customer knowledge and leveraging that information to improve customer experience

Explanation:

Consumers are at the heart of all businesses as they are the ones who our product are targeted. They purchase these goods and the company makes profit. Therefore, it is paramount for businesses to identify their target consumers in other to understand their preference and serve them accordingly. With data analytics, a consumers purchase history, likes and viewed products may be used to improve relationship between consumers and service providers. Once a consumer's preference is anlysed using data, then this is leveraged to improve the kind of service offered to such consumer leasing to better consumer experience.

4 0
3 years ago
Least common multiple of 78,90, and 140
Daniel [21]
The least common multiple (LCM) of 78, 90, and 140 is: 16,380

78 × 210 = 16,380
90 × 182 = 16,380
140 × 117 = 16,380
5 0
3 years ago
Read 2 more answers
Do you think your generation will change the world? Why or why not?
Aleksandr [31]

Answer:

I think it will

Explanation:

because we are very rebellious and like Takis with ketchup I love ice cream with mayonnaise<3

7 0
2 years ago
Read 2 more answers
What type of space is often the main focal point of the composition in graphic design
iogann1982 [59]

Answer: what are the choices?

Explanation:

3 0
3 years ago
Other questions:
  • Esther has acquired an associate's degree in information technology and certifications in PageMaker and Illustrator. Which caree
    8·2 answers
  • What computer company was founded in 1975?
    6·1 answer
  • How do you get 99 points on sunny meadows simulation?
    6·2 answers
  • n physics, a common useful equation for finding the position s of a body in linear motion at a given time t, based on its initia
    9·1 answer
  • Rob creates a Course_Details table that has four columns: Course _ID, Course_Name, Semester and Credits. A course may have 0.5 c
    6·2 answers
  • What led to fall of axum?
    15·2 answers
  • What is DATE data type and its syntax and what is TIMESTAMP data type and its syntax in SQL language.Explain the difference betw
    14·1 answer
  • In order for bitlocker to protect the system volume without the aid of an external drive, your computer must:
    12·2 answers
  • Implement a program called genes.py that does the following: a. Reads a DNA sequence t as command-line argument b. Reads strings
    9·1 answer
  • Kenny FRIEND ME. Ps that is my brother
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!