PYTHON!!!!! 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. Define these functions, median and mode, 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 using the following list defined in main: lyst = [3, 1, 7, 1, 4, 10] An example of the program output is shown below: List: [3, 1, 7, 1, 4, 10] Mode: 1 Median: 3.5 Mean: 4.33333333333333

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PYTHON!!!!!

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. Define these functions, median and mode, 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 using the following list defined in main:

lyst = [3, 1, 7, 1, 4, 10]

An example of the program output is shown below:

List: [3, 1, 7, 1, 4, 10]

Mode: 1

Median: 3.5

Mean: 4.33333333333333
 
 

Program produces correct output given input:

 

Custom Test:

mode method test

Test Contents:

import stats

assert(stats.mode([3, 1, 7, 1, 4, 10]) == 1)

assert(stats.mode([1, 1, 2, 3, 5, 8, 13, 21]) == 1)

assert(stats.mode([10, 13, 78, 69, 45, 23, 32, 23]) == 23)
 
 
 
 
Custom Test:
 
median method test
 
Test Contents:
 
import stats
 
assert(stats.median([3, 1, 7, 1, 4, 10]) == 3.5)
 
assert(stats.median([1, 1, 2, 3, 5, 8, 13, 21]) == 4.0)
 
assert(stats.median([10, 13, 78, 69, 45, 23, 32, 23]) == 27.5)
 
 
 
Custom Test:
 
mean method test
 
Test Contents:
 
import stats
 
assert(stats.mean([3, 1, 7, 1, 4, 10]) == 4.333333333333333)
 
assert(stats.mean([1, 1, 2, 3, 5, 8, 13, 21]) == 6.75)
 
assert(stats.mean([10, 13, 78, 69, 45, 23, 32, 23]) == 36.625)
 
 
 
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education