CODEDRAGON ㆍDevelopment/Python
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)
|
'Development > Python' 카테고리의 다른 글
36 Amazing Python Open Source Projects (v.2019) (0) | 2019.04.25 |
---|---|
머신러닝 용어집 (0) | 2019.04.20 |
if문 형식 (0) | 2019.04.14 |
Data ScienceTutorial for Beginners (0) | 2019.04.09 |
Visual Studio Tools for AI 설치 (0) | 2019.04.03 |