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
Vlada [557]
4 years ago
8

Create an array of strings. Let the user decide how big this array is, but it must have at least 1 element. Prompt them until th

em give a valid size. Prompt the user to populate the array with strings Display the longest and shortest string Input an array size for you words array: 5 Now please enter 5 words Input a word: apples Input a word: eat Input a word: banana Input a word: spectacular Input a word: no The longest word is : spectacular The shortest word is : no
Computers and Technology
1 answer:
Brums [2.3K]4 years ago
5 0

Answer:

lst = []

n = int(input("Input an array size for you words array: "))

print("Now please enter " + str(n) + " words")

max = 0

min = 1000

index_min = 0

index_max = 0

for i in range(n):

   s = input("Input a word: ")

   lst.append(s)

   if len(s) >= max:

       max = len(s)

       index_max = i

   if len(s) <= min:

       min = len(s)

       index_min = i

print("The longest word is :" + lst[index_max])

print("The shortest word is :" + lst[index_min])

Explanation:

Create an empty list, lst

Get the size from the user

Create a for loop that iterates "size" times

Inside the loop, get the strings from the user and put them in the lst. Find the longest and shortest strings and their indices using if structure.

When the loop is done, print the longest and shortest

You might be interested in
What type of program is Microsoft® Excel®?
8090 [49]

Answer:

the answer is spreadsheet application. I hope it helps

7 0
3 years ago
Read 2 more answers
Which asynchronous electronic community is also known as a forum?
Semmy [17]
What are the choices?
Message Boarding is the asynchronous electronic that is know as a forum.
3 0
4 years ago
Read 2 more answers
Write a function that reads from a file the name and the weight of each person in pounds and calculates the equivalent weight in
spayn [35]

Answer:

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

int main(){

   string name;

   double weightKg, weightPd;

   cout<< fixed << setprecision(2);

   fstream myFile("filename.txt");

   while (getline( myFlie, name, weightPd)){

       weightKg = weight * 0.453592;

       cout<< name << weightPd <<weightKg;

   }

   myFile.close();

}

Explanation:

The C++ source code reads in the content of a file that has a name and weight value in pounds and outputs the name, weight in pounds and the weight in kilograms.

3 0
3 years ago
Write an algorithm and draw a flowchart for switching off a machine after it has made 500 glass bottles. use an appropriate cond
masha68 [24]

The algorithm is as follows:

1. Start

2. bottles = 0

3. While bottles != 500

3.1 Create bottle

3.2 bottle = bottle + 1

4. Switch off machine

5. Stop

Explanation:

This begins the algorithm

1. Start

This initializes bottles to 0

2. bottles = 0

The loop is repeated until 500 bottles is created

3. While bottles != 500

This creates a new bottle

3.1 Create bottle

This increments the number of bottles by 1

3.2 bottle = bottle + 1

This switches of the machine after all bottles are created

4. Switch off machine

End algorithm

5. Stop

THANKS

4 0
3 years ago
I need help with cisco please
Dmitry [639]

A cisco develops, manufactures and sells networking hardware, software, telecommunications equipment and other high-technology services and products. ... They pioneered the concept of a local area network (LAN) being used to connect geographically disparate computers over a multiprotocol router system.

Hope that helps.

4 0
3 years ago
Other questions:
  • What are the three business writing formats
    12·1 answer
  • What connector has 4 pins, is used for older IDE drives and some SATA drives, and can provide +5 V and +12 V power outputs?
    11·1 answer
  • Is it possible for the front and rear references in a circular array implementation to be equal?
    8·1 answer
  • Which describes the first step a crawler-based search engine uses to find information?
    10·2 answers
  • Information is best described as
    10·1 answer
  • Public class Square extends Shape{
    13·1 answer
  • HELP
    11·1 answer
  • Do you trust machine learning application?
    10·1 answer
  • What is the correct format to use when<br> inserting a date in Excel?
    15·1 answer
  • Which of the following is not considered essential for an electronic device to be called a computer?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!