Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

costained in the file trlangle, Py and determiet the eutput preduced on sists the lines of cose. import triangle t= triangle. Triang1 o f) print(t.getDase

image text in transcribed
image text in transcribed
image text in transcribed
costained in the file trlangle, Py and determiet the eutput preduced on sists the lines of cose. import triangle t= triangle. Triang1 o f) print(t.getDase ( j) Uowistinjall sLouejal triangle . Friangl e () print(t,area ()) a import triangle t= triangle. Triang1 e(4) print (t,getBase f 3) I impert triangle t - triangle, Triang le () t, setheight (5) print(t,getHeig he()) = import triang1e t= triangle Triangle (4,5) print(t, area()) Question 3: Determine the output of the code where the code uses the following classes: class RegularPolygon: def_init_(self, side=1): self._side = side class Square (RegularPo lygon): def area (self, side): return side * side class Equilateraltriangle (Regu larpolygon): def area (self, side) : return side * side * 0.433 1. sq = Square () print (sq.ar ea (2)) 2.et = Equilateraltriangl e () print (et.area (1)) 1. sq = Square() et = EquilateralTriang le() print (et.area (sq. area (2))) 4. sq = Square() et = EquilateralTriang le() print(sq.area (et. area (2))) Question 4: What is the output of the following program? def main(): r= Rectangle (2,3) print("The (0) has area (1:, , 2f \} . ". format ( r, name (), r. area ())) class Shape: def_init_(self, width=1, height=1): self._width= width self. height = height def setwidth (self, width) : self, width = width de f setheight (self, height) : self._height = height class Rectangle (Sh ape): def name (self): return "rectangle" def area (self): return (self._width * self,_height) main() Question 5: Assume that the code shown below is contained in the file point. Py. class Point: def_init_(self, x,y) : self._x =x self. y=y def distanceFromorigin(self): return (self., 2+ self., y 2) .5 1. Point in Plane Write a program that requests the coordinates of a point as input and then displays the distance of the point from the origin

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe how theories advance psychological science.

Answered: 1 week ago