Create a class called StatSet that can be used to do simple statistical calculations

Chapter 11, Problem 16

(choose chapter or problem)

Get Unlimited Answers
QUESTION:

Create a class called StatSet that can be used to do simple statistical calculations. The methods for the class are:

\(\begin{array}{l}\text{init_(self) Creates a StatSet with no data in it.}\\
\text{addNumber } (\operatorname{sel} f, x) \quad x \text{ is a number. Adds the value } x \text{ to the statSet.}\\
\text{mean(self) Returns the mean of the numbers in this statSet.}\\
\text{median (self) Returns the median of the numbers in this statSet.}\\
\text{stdDev (self) Returns the standard deviation of the numbers in this statSet.}\\
\text{count (self) Returns the count of numbers in this statSet.}\\
\text{min(self) Returns the smallest value in this statSet.}\\
\max \text{ (self) Returns the largest value in this statSet.}\end{array}\)

Test your class with a program similar to the simple statistics program from this chapter.

Questions & Answers

QUESTION:

Create a class called StatSet that can be used to do simple statistical calculations. The methods for the class are:

\(\begin{array}{l}\text{init_(self) Creates a StatSet with no data in it.}\\
\text{addNumber } (\operatorname{sel} f, x) \quad x \text{ is a number. Adds the value } x \text{ to the statSet.}\\
\text{mean(self) Returns the mean of the numbers in this statSet.}\\
\text{median (self) Returns the median of the numbers in this statSet.}\\
\text{stdDev (self) Returns the standard deviation of the numbers in this statSet.}\\
\text{count (self) Returns the count of numbers in this statSet.}\\
\text{min(self) Returns the smallest value in this statSet.}\\
\max \text{ (self) Returns the largest value in this statSet.}\end{array}\)

Test your class with a program similar to the simple statistics program from this chapter.

ANSWER:

Step 1 of 3

Here, first we need to create a class StatSet that can be used to do simple statistical calculations. So a class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made.  Classes are created by the keyword ‘class’.

Then we need to write all these methods within the given class. A method in python is somewhat similar to a function, except it is associated with objects/classes. Methods in python are very similar to functions except for two major differences. The method is implicitly used for an object for which it is called. The method is accessible to data that is contained within the class.

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back