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
HELP PLEASE
Mashcka [7]

A typical example of a Soft skills based question will be "tell us about your interpersonal skills" and "tell us about your time management".

<h3>What are Soft skills?</h3>

Soft skills refers to skills and traits that help employees interact with others and succeed in a typical workplace.

Some example of Soft skills include:

  • interpersonal skills
  • communication skills
  • listening skills
  • time management
  • empathy skills etc

Hence, an example of a Soft skills based question will be "tell us about your interpersonal skills" and "tell us about your time management".

Read more about Soft skills

<em>brainly.com/question/8381292</em>

3 0
1 year ago
BRIANLIEST!!!!!!!!!!!!!!!!
oksano4ka [1.4K]

Answer:

First Line indent

Explanation:

should be correct

4 0
2 years ago
Read 2 more answers
The official record of a high school student's performance is called:
Ivanshal [37]
The answer is transcript. When you apply for colleges and they want to see your high school records, they simply ask for your transcript. Hope I helped :)
5 0
3 years ago
You want to create a directory called ~/Documents/papers, but you’re not sure that the ~/Documents directory exists. What comman
SCORPION-xisa [38]

Answer: e) mkdir -p ~/Documents/papers

Explanation:

As the question says we want to create a directory called ~/Documents/papers, but we are not sure whether it exist or not so we would type the command for making directory starting with mkdir.

Here mkdir means make directory. Followed by mkdir we will use -p. Here p is used to create all the directories for getting us the directory we want and its advantage is that it would ignore all the errors if the directory already exist.

Followed by the name of the directory that we want to create.

So the desired answer for the given condition would be mkdir -p ~/Documents/papers

5 0
2 years ago
What is the differnce between ''P4 and 4P''
34kurt
The number and letter are switched. This question needs more context to get a accurate answer.
5 0
2 years ago
Read 2 more answers
Other questions:
  • Objective:This assignment is designed to give you experience with thinking about algorithm analysis and performanceevaluation.Pr
    11·1 answer
  • Mary is writing an article about the animal kingdom. She wants to place image below the text. Which menu should Mary choose for
    15·2 answers
  • PreparedStatement ps = connection.prepareStatement("select firstName, mi, lastName from Student where lastName = ?"; ps.setStrin
    5·1 answer
  • Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
    5·1 answer
  • An individual who understands and uses a variety of symbols yet uses one symbol at a time to share a message needs more developm
    10·1 answer
  • Similarites between hardware and software
    9·1 answer
  • Find the simple interest Jay owes on a five-year student loan of $48,000 with an annual interest rate of 5%.
    6·1 answer
  • According to the video, what kinds of projects would Computer Programmers be most likely to work on? Check all that apply.
    13·2 answers
  • Stock Market
    11·1 answer
  • List any three positive impact of a computer​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!