달력

4

« 2020/4 »

  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  •  
  •  



 

 

 

1

다음 소스 코드를 완성하여 사각형의 넓이가 출력되게 만드시오.

class Rectangle:

    def __init__(self, x1, y1, x2, y2):

        self.x1 = x1     

    _________________________

    _________________________

        self.y2 = y2

 

rect = Rectangle(x1=20, y1=10, x2=40, y2=30)

 

 

width = abs(rect.x2 - rect.x1)

_________________________

 

area = _________________________ * height

 

print(area)

 

 

 

 

 

class Rectangle:

    def __init__(self, x1, y1, x2, y2):

        self.x1 = x1

        self.y1 = y1

        self.x2 = x2

        self.y2 = y2

 

rect = Rectangle(x1=20, y1=10, x2=40, y2=30)

 

 

width = abs(rect.x2 - rect.x1)

height = abs(rect.y2 - rect.y1)

area = width * height

 

print(area)

 

 

 

 


Posted by codedragon codedragon

댓글을 달아 주세요