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
Dmitry_Shevchenko [17]
3 years ago
10

Define and use in your program the following functions to make your code more modular: convert_str_to_numeric_list - takes an in

put string, splits it into tokens, and returns the tokens stored in a list only if all tokens were numeric; otherwise, returns an empty list. get_avg - if the input list is not empty and stores only numerical values, returns the average value of the elements; otherwise, returns None. get_min - if the input list is not empty and stores only numerical values, returns the minimum value in the list; otherwise, returns None. get_max - if the input list is not empty and stores only numerical values, returns the maximum value in the list; otherwise, returns None.
Computers and Technology
1 answer:
Lelechka [254]3 years ago
7 0

Answer:

In Python:

def convert_str_to_numeric_list(teststr):

   nums = []

   res = teststr.split()

   for x in res:

       if x.isdecimal():

           nums.append(int(x))

       else:

           nums = []

           break;

   return nums

def get_avg(mylist):

   if not len(mylist) == 0:

       total = 0

       for i in mylist:

           total+=i

       ave = total/len(mylist)

   else:

       ave = "None"

   return ave

def get_min(mylist):

   if not len(mylist) == 0:

       minm = min(mylist)

   else:

       minm = "None"

   return minm

def get_max(mylist):

   if not len(mylist) == 0:

       maxm = max(mylist)

   else:

       maxm = "None"

   return maxm

mystr = input("Enter a string: ")

mylist = convert_str_to_numeric_list(mystr)

print("List: "+str(mylist))

print("Average: "+str(get_avg(mylist)))

print("Minimum: "+str(get_min(mylist)))

print("Maximum: "+str(get_max(mylist)))

Explanation:

<em>See attachment for complete program where I use comment for line by line explanation</em>

Download txt
You might be interested in
TRUE OR FALSE!!!!!
VladimirAG [237]
The answer is True.
6 0
3 years ago
Read 2 more answers
Has anyone done the unit 10 lesson 9 encryption/decryption texts on code.org?
Pani-rosa [81]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

5 0
3 years ago
How big was a 10MB disk drive?
guajiro [1.7K]
10 megabytes or 10000 kilobyte
5 0
3 years ago
What are the most common types of tasks performed by utility programs? accessibility
denis23 [38]
The most common type of task performed by utility program is the file management. The utility program is a program created to help computer users in managing, optimizing, and configuring the computer. Every newly purchased computer has a file managing program to help users for setting the computer up for its personal use. Therefore, file managing is the most common utility program.
6 0
3 years ago
Name the written test a potential driver must pass and list the minimum required score to earn a learners license?
Umnica [9.8K]
Re word this plz then I will answer
6 0
3 years ago
Other questions:
  • Marissa works at a company that makes perfume. She noticed many samples of the perfume were not passing inspection. She conducte
    6·2 answers
  • which of the following is true about both the cyber community and the real community like the one you live in,i will give 10 poi
    6·1 answer
  • The basic components of cartridges and shotshells are similar. Shot pellets and a bullet are examples of which basic component?
    13·1 answer
  • Microsoft Xbox operating system provides Xbox programmers with a set of common standards to use to access controllers, the Kinec
    6·1 answer
  • Which of the following jobs is considered part of the information technology industry?
    15·2 answers
  • In bankruptcy, most of a debtor’s assets will probably be used to repay unsecured debt
    9·1 answer
  • Why does brainly keep saying “oops... something went wrong! Try again”
    7·2 answers
  • Oxnard Casualty wants to ensure that their e-mail server has 99.98 percent reliability. They will use several independent server
    14·1 answer
  • Among your selection in different online interfaces, which are your top three favorites?​
    7·2 answers
  • Even though jdoe and jrock have the same password (i.e., hacker), their password hashes in the /etc/shadow file are different. W
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!