-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path00-start.py
More file actions
34 lines (24 loc) · 762 Bytes
/
00-start.py
File metadata and controls
34 lines (24 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from math import pi
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def move_by(self, dx, dy):
self.x += dx
self.y += dy
def __str__(self):
return f'A Point at {self.x}, {self.y}'
def __repr__(self):
return f'{self.__class__.__name__}({self.x}, {self.y})'
class Circle:
def __init__(self, center, radius):
self.center = center
self.radius = radius
@property
def area(self):
return pi * self.radius ** 2
def __str__(self):
return f'A Circle at {self.center.x}, {self.center.y} and ' + \
f'radius {self.radius}'
def __repr__(self):
return f'{self.__class__.__name__}({self.center!r}, {self.radius!r})'