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
Elden [556K]
4 years ago
7

Implement a container class Stat that stores a sequence of numbers and provides statistical information about the numbers. It su

pports an overloaded constructor that initializes the container either by supplying a list or by giving no arguments (which creates an empty sequence). The class also includes the methods necessary to provide the following behaviors:
>>> s = Stat()
>>> s.add(2.5)
>>> s.add(4.7)
>>> s.add(78.2)
>>> s
Stat([2.5, 4.7, 78.2])
>>> len(s)
3
>>> s.min()
2.5
>>> s.max()
78.2
>>> s.sum()
85.4
>>> s.mean()
28.46666666666667
>>> s.clear()
>>> s
Stat([])
If a Stat is empty, several (but not all) methods raise errors. Note that you won’t literally see "…". You will instead see more information on the error.
>>> s = Stat()
>>>
>>> len(s)
0
>>> s.min()
Traceback (most recent call last):
...
EmptyStatError: empty Stat does not have a min
>>> s.max()
Traceback (most recent call last):
...
hw3.EmptyStatError: empty Stat does not have a max
>>> s.mean()
Traceback (most recent call last):
...
hw3.EmptyStatError: empty Stat does not have a mean
>>> s.sum()
0
Computers and Technology
1 answer:
olga2289 [7]4 years ago
6 0

Answer:

See explaination

Explanation:

Definition of Class 1:

class Stat:

def __init__(self, li):

self.li = li

def add(self, value):

self.li.append(value)

def __len__(self):

return len(self.li)

def min(self):

try:

return min(self.li)

except:

return "EmptyStatError: empty Stat does not have a min"

def max(self):

try:

return max(self.li)

except:

return "EmptyStatError: empty Stat does not have a max"

def sum(self):

return sum(self.li)

def mean(self):

try:

return float(sum(self.li))/float(len(self.li))

except:

return "EmptyStatError: empty Stat does not have a mean"

def __getitem__(self):

return self.li

def clear(self):

del self.li[:]

Definition of Class 2:

class intlist:

def __init__(self, li):

self.li = li

def append(self, value):

if type(value) == int:

self.li.append(value)

else:

print "NotIntError: Input is not an Integer."

def insert(self, index,value):

if type(value) == int:

self.li.insert(index, value)

else:

print "NotIntError: Input is not an Integer."

def extend(self, value):

i = 0

for temp in value:

if type(temp) == int:

i = i

else:

i = i+1

if i==0:

self.li.extend(value)

else:

print "NotIntError: Input is not an Integer."

def __setitem__(self, index, value):

self.insert(index, value)

def __getitem__(self, index):

return self.li[index]

def odds(self):

lis = []

for temp in self.li:

if temp%2 == 1:

lis.append(temp)

return lis

def evens(self):

lis = []

for temp in self.li:

if temp%2 == 0:

lis.append(temp)

return lis

Class 1 call:

s = Stat([])

s.add(2.5)

s.add(4.7)

s.add(78.2)

print len(s)

print s.min()

print s.max()

print s.sum()

print s.mean()

print s.li

s.clear()

print s.li

print len(s)

print s.min()

print s.max()

print s.mean()

print s.sum()

Class 2 call:

intl = intlist([])

print intl.li

intl = intlist([1,2,3])

print intl.li

intl.append(5)

print intl.li

intl.insert(1,99)

print intl.li

intl.extend([22,44,66])

print intl.li

print intl.odds()

print intl.evens()

print intl.li

intl[2] = -12

print intl[4]

You might be interested in
If you answer these questions correctly I will mark you BRAINLIST.
dezoksy [38]

Answer:

• a break element is used to break a while loop in python.

• the <p></p> element is the paragraph element in html. For example a note could be <em><p>This paragraph is important.</p> </em>When highlighting something important, use the <em>strong </em>tag or <em>mark</em> tag.

<em>• </em>the <hr> function can be used to separate a title from multiple columns or paragraphs to give a more bootstrap(probably 3 or 4) look.

• the body element is extremely important in HTML because if you don't have a body, you can't write working code-lines.

5 0
2 years ago
For the following 4-bit operation, assuming these register are ONLY 4-bits in size, which status flags are on after performing t
m_a_m_a [10]

Answer:

All flags are On ( c, z , N  )

Explanation:

Given data:

4-bit operation

Assuming 2's complement representation

<u>Determine status flags that are on after performing </u> 1010+0110

    1   1

    1  0   1  0

    0  1   1  0

  1  0 0 0 0

we will carry bit = 1 over

hence C = 1

given that: carry in = carry out there will be zero ( 0 ) overflow

hence V = 0

also Z = 1      

But the most significant bit is  N = 1

8 0
3 years ago
What are titles that i should talk about in my ppt about history of computer science???????
chubhunter [2.5K]

Talk about who created it when it was created and the begging of it. Talk about how it established over the years. Then talk about the achivements like the first computer.

4 0
3 years ago
Dan wants to use some of his friend's printed photos of sea creatures for a school multimedia project. Which input device is bes
lora16 [44]

Answer:

OC graphics tablet

Explanation: A oc graphics tablet are very expensive and are mainly used in high tech computers for better graphics.

5 0
3 years ago
Musccanic Inc., a company that manufactures microprocessors, updates the technology used in its microprocessors once every four
ELEN [110]

Answer:

S-curve pattern of innovation.

Explanation:

Based on the information provided with regards to Musccanic Inc.'s microprocessor production cycle, it can be said that this scenario illustrates the S-curve pattern of innovation. This term refers to the slow rise in profits as a product enters a market, then the rapid rise as it hits its maturity stage, and then the decline as it reaches the end of it's life cycle, usually when an updated version is going to be released. Which in this scenario is every 4 years when a new microprocessor is going to be released.

If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Other questions:
  • Where do you go to create a workbook?​
    8·1 answer
  • Give an example of an outdated memory or storage device what do you think they are outdated
    12·1 answer
  • Does anyone know what type of Honda this is and the year of it lol this isn’t school related
    10·1 answer
  • Google Glass, glasses that allow you to take pictures and search online by speaking commands, are introduced at a technology tra
    8·1 answer
  • What is technology??
    12·1 answer
  • The key uniquely identifies each record
    9·1 answer
  • Explain the risks to privacy from collecting and storing personal data on computer systems and the programmer’s role to safeguar
    11·1 answer
  • The current annual interest rate is 5 percent, and you are taking out a 20-year loan with a monthly end-of-month payment. If you
    5·1 answer
  • Which of the following makes Super Mario Run unique?
    6·1 answer
  • Which option in PowerPoint allows users to configure the number of columns and rows manually, using numerical values?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!