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
The LList class is (mostly) the same one discussed in lecture, but you must write a sort() function that uses one of the three i
Vladimir79 [104]

Answer:

see explaination

Explanation:

#include <iostream>

#include <string>

using namespace std;

class LinkedList{

class Node{

public :

int data;

Node* next;

Node(int data){

this->data = data;

next = NULL;

}

};

public :

Node *head;

LinkedList(){

this->head = NULL;

}

void insert(int d){

Node* new_node = new Node(d);

new_node->next = head;

head = new_node;

}

// sort the list with selection sort algorithm.

// Pick the smallest element in the unsorted array and place in the first element in the unsorted.

void sort_list(){

if (head == NULL){

return;

}

Node* current = head;

while (current->next != NULL){

Node* min_node = current;

Node* traverse = current->next;

while(traverse != NULL){

if(traverse->data < min_node->data){

min_node = traverse;

}

traverse = traverse->next;

}

int temp = current->data;

current->data = min_node->data;

min_node->data = temp;

current = current->next;

}

}

void print_list(){

Node* current = head;

while(current !=NULL){

cout<<current->data<<" ";

current = current->next;

}

cout<<"\n";

}

};

int main(){

LinkedList ll;

for(int i=0;i<10;i++){

ll.insert(i);

}

ll.print_list();

cout<<"*******************************************\n";

ll.sort_list();

ll.print_list();

cout<<"*******************************************\n";

}

8 0
3 years ago
True or false? any webb app can be accessed and run on any computing
Mademuasel [1]

Answer:

B. False

Explanation:

A web application is a computer program that  works over the internet. So, in order to access and run it you need a web browser and this will also require to have an internet access. If you don't have one of these you will not be able to run the app.

6 0
2 years ago
A system developer needs to provide machine-to-machine interface between an application and a database server in the production
nordsb [41]

Answer:

The correct option is (d) Use a service account and prohibit users from accessing this account for development work

Explanation:

Solution

As regards to the above requirement where the application and database server in the production environment will need to exchange the data once ever day, the following access control account practices would be used in this situation:

By making use of a service account and forbids users from having this account for development work.

The service account can be useful to explicitly issue a security context for services and thus the service can also access the local and the other resources and also prohibiting the other users to access the account for the development work.

Submitting an adhoc request daily is not a choice as this is required daily. Also, the servers can be different and cannot be put in one place. and, we cannot make use of the read-write permission to the members of that group.

7 0
3 years ago
Which invention replaced vacuum tubes in computers?
dlinn [17]

Answer:

Transistors

Explanation:

6 0
2 years ago
What are several networks connected together using a router
elixir [45]

Answer:

local Area Network, Wide Local Area Network and Personal Area Network

8 0
3 years ago
Other questions:
  • What is basic function of an operating system?
    10·2 answers
  • Convert 578.2 into hexadecimal​
    13·1 answer
  • To select all the text in a document, press ____.
    12·2 answers
  • How can I make my Wi-Fi signal fast? I am going through my exam but my Wi-Fi is not supporting plz help.
    12·1 answer
  • What is the name of the option in most presentation applications with which you can modify slide elements?
    14·1 answer
  • The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
    10·1 answer
  • Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, g
    7·2 answers
  • Who is the intended audience of a pseudocode document?
    14·1 answer
  • ASAP BRAINLIEST!!!
    10·1 answer
  • terms found in provider documentation (e.g., difficult, extensive, or unusual) would support adding modifier to a cpt code.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!