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
erastova [34]
3 years ago
6

Define and implement a method that takes a string array as a parameter and returns the length of the shortest and the longest st

rings in the array
Computers and Technology
1 answer:
Drupady [299]3 years ago
7 0

Answer:

#HERE IS CODE IN PYTHON

#function to find length of shortest and longest string in the array

def fun(list2):

   #find length of shortest string

   mn=len(min(list2))

   #find length of longest string

   mx=len(max(list2))

   #return both the value

   return mn,mx

#array of strings

list2 = ['Ford', 'Volvo', 'BMW', 'MARUTI','TATA']

# call the function

mn,mx=fun(list2)

#print the result

print("shortest length is:",mn)

print("longest length is:",mx)

Explanation:

Create an array of strings.Call the function fun() with array as parameter. Here min() function will find the minimum string among all the strings of array and then len() function will find its length and assign to "mn". Similarly max() will find the largest string and then len() will find its length and assign to "mx". Function fun() will return "mn" & "mx".Then print the length of shortest and longest string.

Output:

shortest length is: 3

longest length is: 5

You might be interested in
To maintain her audience's confidence in her, what should kiara not do while delivering her presentation?
IrinaVladis [17]
Use filler words like ummmm, like, so, kinda, or such. Faltering on her words, forgetting things, or not saying things with confidence wouldn't help either. Also, do not loose eye contact with the people even if you only occasionally look up, it makes you look nervous and like you don't know what you're talking about.
7 0
3 years ago
Given the char variable c, write an expression that is true if and only if the value of c is not the space character .
saw5 [17]
If( c != ' ' )
  /*Do something*/
6 0
3 years ago
Write a generic C++ function that takes an array of genericelements and a scalar of the same type as the array elements. Thetype
siniylev [52]

Answer:

Explanation:

Here is the code

#include<iostream>

using namespace std;

template <class myType>

int generic(myType *a, myType b)

{

int i;

for(i=0;a[i]!=-1;i++)

{

       if( b == a[i])

       return i;

}

return -1;

}

int main()

{

int a[]={1,2,3,4,5,6,7,8,-1};

float b[]={1.1,2.1,3.1,4.1 ,5.1,6.1,7.1,-1};

if(generic(a,5)>0)

       {

       cout<<" 5 is foundin int at index "<<generic(a,5)<<endl;

       }

       else

       {

       cout<<" 5 notfound "<<endl;

       }

if(generic(b,(float)5.1)>0)

       {

       cout<<" 5.1 isfound in float at index "<<generic(a,5)<<endl;

       }

       else

       {

       cout<<" 5.1 notfound "<<endl;

       }

system("pause");

}

/*

sample output

5 is found in int at index 4

5.1 is found in float at index 4

*/

7 0
3 years ago
Which part of the cryosphere comes directly from the atmosphere?
marin [14]
The answer to this question is C.
4 0
3 years ago
Read 2 more answers
Which of the following definition below describes a wall opening?
My name is Ann [436]
A. An opening at least 30 inches high and 18 inches wide in any wall or partition. 
5 0
3 years ago
Read 2 more answers
Other questions:
  • Use the script below as a starting point to create a Rectangle class. Your rectangle class must have the following methods;A con
    12·1 answer
  • Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
    14·1 answer
  • What is the smallest unit of data on the hard drive?
    5·1 answer
  • If you were to mount a nonmetallic box to the front of a stud, what type of bracket should the box have? A. FP B. BP C. NP D. JP
    13·1 answer
  • If you wanted to share a statement of the company's financial position at a certain time, you would use a _____.
    12·2 answers
  • What are the features of Cobol language that make it suitable for programming business applications.
    6·1 answer
  • The 7-bit ASCII code for the character ‘&amp;’ is: 0100110 An odd parity check bit is now added to this code so 8 bits are trans
    12·1 answer
  • When we code an algorithm, we need to provide the commands in the order we want the
    10·1 answer
  • Plzz help me with this question.........
    6·1 answer
  • Using a computer application is known as​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!