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
Carbon monoxide poisoning can result from breathing
Mamont248 [21]
The answer is the letter a
6 0
3 years ago
A _____ is a collection of (potentially) thousands of computers that can respond to requests over a network
Rom4ik [11]

Answer:

server or supercomputer

Explanation:

5 0
2 years ago
What is the output of the given code?<br><br> A. Compiler error<br> B. 0505<br> C. Smooth<br> D. 0.0
oksano4ka [1.4K]

Answer:

The answer is A. Compile error

Explanation:

In the class Fabric, fabricID has private access. You can only print out out private variables in the class or function they are assigned in.

ps: sorry if I am wrong, I am kind of new to java

6 0
3 years ago
Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
sammy [17]

Answer:

Option d is the correct answer for the above question.

Explanation:

  • The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
  • The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
  • Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
  • The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
  • So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
  • Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
3 0
3 years ago
Data frames can be subset by a chosen value using ==.
balandron [24]

Using python knowledge and writing code importing pandas, it is possible to create a function that corresponds to what you want.

<h3>Writting in python:</h3>

<em>import pandas as pd</em>

<em>if __name__ == "__main__":</em>

<em>    df=pd.read_csv('mtcars.csv')</em>

<em>    cylinders=int(input())</em>

<em>    print(df[df.cyl==cylinders].shape)</em>

See more about python at brainly.com/question/18502436

#SPJ1

5 0
2 years ago
Other questions:
  • Witch printer covers a large range of colors than any other printer does
    15·2 answers
  • What is being measured using kbps, mbps, and gbps?
    7·1 answer
  • A _______ record is responsible for resolving an ip to a domain name.
    9·1 answer
  • Maia notices that her paragraphs are too close to one another. She wants to increase the space. Which arrangement of steps does
    6·2 answers
  • Explain the role of the network layer and Internet protocol (IP) in order to make internetworking possible.
    8·1 answer
  • Software built and delivered in pieces is known as
    14·2 answers
  • The data type of 17.3 should be ________________.
    12·2 answers
  • What is one way that Accenture helps clients ensure fairness when applying AI solutions?
    13·1 answer
  • A _is a short descriptive label that you assign to webpages, photos,
    10·1 answer
  • By itself, the human eye cannot see anything in three dimensions. What does the passage say enables us to see the world in 3-D?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!