-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-square.py
executable file
·44 lines (34 loc) · 891 Bytes
/
4-square.py
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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python3
"""A module containing a square"""
class Square:
"""A square class"""
def __init__(self, size=0):
"""initializes square
Args:
size (int): size of the square
"""
self.size = size
@property
def size(self):
"""Gets value of size
Returns:
size (int)
"""
return self.__size
@size.setter
def size(self, value):
""" Change the value of size
Args:
value (int): new value of size
"""
if type(value) != int:
raise TypeError("size must be an integer")
elif value < 0:
raise ValueError("size must be >= 0")
self.__size = value
def area(self):
""" Calculates the area of a square
Returns:
area
"""
return self.__size * self.__size