As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the same place. For this task, you'll implement a class DataFrame that maintains a collection of data items inside self.items, which you keep as a list of floats, and provides the following operations: 1. Upon creation (remember that 2. A class method def add(self, x) will add either x or the members of x to the list self.items. Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added to the list directly. If x is a list or a tuple, its members are individually added to the list. 3. A class method mean(self) will compute and return the mean of the data maintained in the Linit_ function?), the collection is empty. collection.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Python Program: Statistically Speaking

As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the
same place. For this task, you'll implement a class DataFrame that maintains a collection of data items
inside self.items, which you keep as a list of floats, and provides the following operations:
_init__function?), the collection is empty.
1. Upon creation (remember that
2. A class method def add(self, x) will add either x or the members of x to the list self.items.
Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added
to the list directly. If x is a list or a tuple, its members are individually added to the list.
3. A class method mean(self) will compute and return the mean of the data maintained in the
collection.
4. A class method percentile(self, r) will compute and return the value at the r-th percentile
of the data in the collection, where r is an integer in [0, 100) (i.e., excluding 100 but including 0).
For this problem, this is the value at the position [G) es (counting from 0) in the sorted list of
values, where l is the size of the collection. As an example, for the data collection [4,2,8,7,3, 1,5],
the 98-th percentile value is 8 because the collection once sorted is [1,2,3,4,5,7,8] and [() e] =
[0.98 × 7] = 6. You may find the built-in function sorted useful.
5. A class method mode (self) will compute and return the mode of the data. The mode of the
data is the item that appears the most often in the dataset (i.e., has the highest frequency). If
many items have the same highest frequency, your function can return any one of them.
6. A class method sd(self) will compute and return the standard deviation of the data. If the data
100
100
items are xo, X1,..., XN-1, use the formula
N-1
E (xi – x)2,
i=0
where N is the number of data items in your collection and x is the mean of the data.
When these methods are called, it is possible that they are interleaved. For example, call add, followed
by another add, then mean, then a couple more add's. It is, however, guaranteed that the collection will
not be
empty
when
your code is asked to report a statistic.
Transcribed Image Text:As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the same place. For this task, you'll implement a class DataFrame that maintains a collection of data items inside self.items, which you keep as a list of floats, and provides the following operations: _init__function?), the collection is empty. 1. Upon creation (remember that 2. A class method def add(self, x) will add either x or the members of x to the list self.items. Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added to the list directly. If x is a list or a tuple, its members are individually added to the list. 3. A class method mean(self) will compute and return the mean of the data maintained in the collection. 4. A class method percentile(self, r) will compute and return the value at the r-th percentile of the data in the collection, where r is an integer in [0, 100) (i.e., excluding 100 but including 0). For this problem, this is the value at the position [G) es (counting from 0) in the sorted list of values, where l is the size of the collection. As an example, for the data collection [4,2,8,7,3, 1,5], the 98-th percentile value is 8 because the collection once sorted is [1,2,3,4,5,7,8] and [() e] = [0.98 × 7] = 6. You may find the built-in function sorted useful. 5. A class method mode (self) will compute and return the mode of the data. The mode of the data is the item that appears the most often in the dataset (i.e., has the highest frequency). If many items have the same highest frequency, your function can return any one of them. 6. A class method sd(self) will compute and return the standard deviation of the data. If the data 100 100 items are xo, X1,..., XN-1, use the formula N-1 E (xi – x)2, i=0 where N is the number of data items in your collection and x is the mean of the data. When these methods are called, it is possible that they are interleaved. For example, call add, followed by another add, then mean, then a couple more add's. It is, however, guaranteed that the collection will not be empty when your code is asked to report a statistic.
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

what is the answer for 3,4,5,6

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY