Ask a New Question

Asked by Joe

Classes Rectangle and Point are defined as follow:

class Point:

def __init__(self,x,y):

self.x = x

self.y = y

class Rectangle:

def __init__(self,p1,p2):

self.p1 = p1

self.p2 = p2

Which option is showing the correct way of calculating the area of the rectangle in the Rectangle class?

a) def area():

return (self.p1.x-self.p2.x) * (self.p1.y-self.p2.y)

b) def area(self):

return (self.p1.x-self.p2.x) * (self.p1.y-self.p2.y)

c) def area(self,p1,p2):

return p1.x-p2.x*p1.y-p2.y

d) def area(p1,p2):

return area(p1*p2)
4 years ago

Answers

Related Questions

Use the rectangle (mid-point) rule, with n=3 to approximate the integral of 2x-x^2 from -6 to 0. P is a point in rectangle ABCD. The distance from P to the 4 vertices of the rectangle are 7,15,24 a... Point P is inside rectangle ABCD. Show that \[PA^2 + PC^2 = PB^2 + PD^2.\] Be sure that your pr... In rectangle ABCD, point A is at (-1,-1) and point B is at (1,2). A diagonal is drawn from point B... For rectangle ABCD point O is right in the middle with A at the bottom left B at the top left C in t... 1. What were the three classes of French society? Tell me what they were specifically. 2. What t... There are 20 classes at each of two middle schools. The number of students in each class at each sch... What are the classes in a Histogram What are the classes in a Histogram if 1 is 23 2 is 54 3 is 75 4 is 32 5 is 54 6 is 67 and 7 is 87
Ask a New Question
Archives Contact Us Privacy Policy Terms of Use