Question: 1. Implement a container class Stat that is a subclass of object. The class stores a sequence of numbers and provides statistical information about the
1. Implement a container class Stat that is a subclass of object. The class stores a sequence of numbers and provides statistical information about the numbers. It supports an overloaded constructor that initializes the container either using a list or with no parameter which creates an empty sequence. The class also includes the methods necessary to provide the following behaviors: >>>s-Stat ) >>> a.min ) 0.0 >S.max ) 0.0 >>> s.sum) 0 >>>s.mean () 0.0 >>s.add (3) >>>s.add ('four) four not added. Value must be a number >>> s.add ('Five') Five not added. Value must be a number. >>s.add (5) >s.min) S.max () >>>s.sum) 12 >>>s.mean ) 4.0 >>s.clear >>> str (s) Stat object with O items. >>s1Stat ([10,20, 30]) >sl.mean ) 20.0 .max ) 0.0 >>>sl.max () 30 This class also implements the- operator eq.It returns true if the SUM of the values is the same. Example: >>>s1-Stat ([1,2,3]) >>> s2-Stat ((3,2,1]) >>>s1s2 True >>>s2-stat ((3,2,2]) False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
