Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3+ Adjust the following code so the four errors below are non-present: 1. Stat.__repr__() : No declaration and implementation. Please know what is difference

Python 3+

Adjust the following code so the four errors below are non-present:

1. Stat.__repr__() : No declaration and implementation. Please know what is difference between __str__ and __repr__. (-0.5) 2. Stat.clear() : what is "s"? It cause error. (-0.5) 3. intlist.__repr__() : No declaration and implementation. (-0.5) 4. intlist.extend() : No declaration and implementation. (-0.5)

Code:

image text in transcribed

image text in transcribed

Program 1 class Stat (object): def-init-(self, seq1=None): if seqi is None: self.seq set () else: self.seq set (seql) def len_(self): return len (self.seq) def _repr (self): return()'.format (self.seq) def sum(self): try: print (sum (self.seg)) except: print ("empty Stat does not have a sum" def add (self, val): try: self.seq.add (val) except: print("empty Stat does not have an add") def clear (self): try: print (self.seq.clear )) except: print ("empty Stat does not have a clear") def min (self): try: print (min (self.seq)) except: print ("empty Stat does not have a min") def max (self): try: print (max (self.seg)) except: print ("empty Stat does not have a max" def mean (self): try: 11n=len (self. seq) sim=sum (self. seq) print (sim/lin) except: print("empty Stat has no mean") Program 2 class intlist: def _init_(self, info-None) self.list-info def setitem(self, index, val): self.insert (index, val) def _getitem (self, index): return self.li[index] def evens (self) info- [] for num in self.list: if (val%2-0) : info.append (val) return info def odds (self) info= [] for num in self.list: if (val%2-1) : info.append (val) return info def append (self, val) try: int (val) self.list.append (val) except NotIntError: print ('Not an integer) def insert (self, index, val) try: int (val) self.list.insert (index, val) except NotIntError: print ('Not an integer) def extend (self, info): self.list.extend (info)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions