Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2, (10 points) Given the Python class below, perform the tollowing tasks: a. Nam

ID: 3601096 • Letter: 2

Question

2, (10 points) Given the Python class below, perform the tollowing tasks: a. Name all mutator methods b. Give the output c. Give code to create a sibling class to Rectangle named RightTriangle d. Give code to create a RightTriangle, RT, class Shape: def-init-(self, width, height): self.w-width self.h - height def setwidth (self, width): self.w- width def setHeight (self, height): self.h height class Rectangle (Shape): def name (self) return "rectangle" def area (self): return (self.w self.h) def main): 6) r= Rectangle (3, r.setWidth (4) print ('The '.name () + 'has an area of ' str (r.area ())+ . main ()

Explanation / Answer

2

a)mutator methods

def_init_(self width,height):

def setWidth(self,width):

def setHeight(self,height):

b)output

the rectangle has an area of 18

c)create a sibling class to rectangle named to rectangletriangle

class Rectangle(shape):

def name(self):

return "rectangle"

def area(self)

return (self.h*self.w)

super (Rectangle,self)._init_()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote