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
Setler [38]
3 years ago
12

A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set

of numbers, as defined in Section 5.4. Define these functions in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0 if the list is empty. Include a main function that tests the three statistical functions. Ask users to enter the list of numbers, and then choose which function to apply to those numbers. After the single number is returned from the correct function, display to the user the list of numbers, the function selected and the answer in a format that is easy to understand.
Computers and Technology
1 answer:
Vanyuwa [196]3 years ago
8 0

Answer:

from functools import reduce

def mean(mylist):

   score = reduce(lambda x,y: x + y, mylist)/ len(mylist)

   return score

def median(mylist):

   sorted(mylist)

   list_len = len(mylist) % 2

   i = round(len(mylist)/2)

   x = len(mylist)//2

   if list_len == 0:

       median = (mylist[x] + mylist[x+1]) / 2  

   else:

       median = mylist[i]

   return median

def mode(mylist):

   unique = set(mylist)

   unique = list(unique)

   collector = [mylist.count(key) for key in unique]

   maxi = max(collector)

   loc = collector.index(maxi)

   return unique[loc]

def main():

   scores = input( 'Enter list of numbers: ').split(",")

   scores = [int(score) for score in scores]

   

   operation = input('Enter operation: ')

   operator = ['mean', 'median', 'mode']

   

   for x in iter(list, 0):

       if operation in operator:

           break

       print("Invalid operation: ")

       operation = input('Enter operation')

   

   index_loc = operator.index(operation)

   

   if index_loc == 0:

       return mean(scores)

   elif index_loc == 1:

       return median(scores)

       #return np.median(scores)  can be used of the defined function

   elif index_loc == 2:

       #return stats.mode(scores)[0]  can be used of the defined function

       return mode(scores)

print( main( ) )

Explanation:

The main python function calls conditionally three statistical functions namely mean, median and mode. It prompts for user input for a list of integer numbers and a function name name to return the corresponding result.

You might be interested in
. Assuming each reference costs 1 byte, and each piece of data/info costs 1 byte as well. When will a doubly linked list be more
mixer [17]

Answer:

The circular individually linked list is more efficient for time sharing process ,when multiple application are running on pc it is responsibility of an output system to put all process on a list and execute them all by giving them piece of time and make them wait when cpu is selected to other process.

It will be more suitable for output system to use circular list as when it reaches to last of list it will be manually reaches to starting node or process.

Singly circular linked list is used when we are concerned with the memory as only one process will be allocated memory at once and there are no chances of process to go never-ending waiting.

Explanation:

4 0
3 years ago
In 2016, NIST published a new Federal Master Cybersecurity Framework to create a mandatory framework for managing cybersecurity
ICE Princess25 [194]

Answer:

In 2014, NIST published a new Federal Master Cybersecurity Framework for managing cyber risk for the delivery of critical services. So the correct answer is False.

Explanation:

NIST published the Federal Master Cybersecurity Framework to managing risk for the delivery of critical services. The U.S. issued Framework on February 12, 2014.

8 0
3 years ago
Please help asap
NNADVOKAT [17]

Answer:

a. Comparison of if-else and elif:

if else follow as:

If (Condition)

{

In case if condition true, expression in this section executes

}

else

{

In case condition is false, expression in this section executes

}

elif Statement follows as:

If (Condition)

{

In case if condition true, expression in this section executes

}

{

in case, condition is false, move to elif block

elif (Condition)

{

In case elif condition true, expression in this section executes

}

else

{

In case elif condition is false, expression in this section executes

}

}

Explanation:

In if else, program first check the condition in "if statement", if condition is true it move into the body of "if " and execute the expression. If the condition is false it moves to the body of "else" and execute the expression.

elif is another block of condition in If else condition,It works as in "if statement" if the condition is true the program executes the expression of body of "if body". If the condition is false, it moves to another block of "elif", where it again check some other condition found in "elif statement". If the condition of "elif statement" is true it executes the expression of "elif body" otherwise in case of false condition it execute the expression in "else body".

It follows as: if - elif-else

Answer

b. the relational operators

Relation operators are the operators that are need in the expression to establish relationship between different operands of the expression.

Explanation:

In few expressions, their are some operators used to establish or show the relationship between different operands. These operator could be Equal (=), Greater than(>), Less than (<), Greater than equal to (>=) and Less than Equal to (<=).

These operators can be used in conditional statements that are used to check the relationship between operands and values through these operators.

Example

if (a>5)

{

if value of is greater than 5 then body of if will execute.

}

else

{

If value of a is less or equal to 5, this section will execute.

}

5 0
3 years ago
Which of the following concepts is linked the least with Henry Ford? A. interchangeable parts B. technology C. mass customizatio
Burka [1]

Answer:

C. mass customization

Explanation:

Based on the information provided within the question it can be said that the concept that is least linked to Henry Ford would be mass customization. This term refers to large corporation that allow customers to customize their products when ordering. Henry Ford has not done this with his car products and were all built based on his standards.

6 0
4 years ago
I can't seem to find anything about Sand Tables as a computational device. Can anyone give me some resources or explain the hist
-BARSIC- [3]
The sand table is a device used by Egyptians to send messages
6 0
3 years ago
Other questions:
  • What will happen with communication methods in five years?
    8·1 answer
  • A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
    7·1 answer
  • You recently upgraded your computer and added an extra 512 MB of RAM. Consequently, you want to increase your swap space by addi
    10·1 answer
  • Answer for a, b, and c
    7·1 answer
  • A document created by the scriptwriter that contains general information about a program is called _____.
    15·1 answer
  • Making phone calls with a public box
    11·1 answer
  • The cause of french revolution and anayze the reason for significane out come
    6·1 answer
  • What are the oop concept of java
    5·2 answers
  • Tina has taken the time to modify font sizes and colors in a text box and would like to duplicate those settings on other text b
    12·2 answers
  • This is on zyBooks. Please write the code in C++, please!
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!