-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5-square.py
More file actions
executable file
·46 lines (35 loc) · 997 Bytes
/
Copy path5-square.py
File metadata and controls
executable file
·46 lines (35 loc) · 997 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
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3
"""Defines class Square
"""
class Square():
"""Square class
Args:
size: The size of the square
"""
def __init__(self, size=0) -> None:
"""Init of an instance of squere.
Args:
size (int): The size of the square
"""
self.__size = size
@property
def size(self):
return (self.__size)
@size.setter
def size(self, size):
if type(size) is not int:
raise TypeError("size must be an integer")
elif size < 0:
raise ValueError("size must be >= 0")
self.__size = size
def area(self):
"""Give the current square area"""
return (self.__size**2)
def my_print(self):
"""Prints in stdout the square with the character #"""
_print = ""
for i in range(self.__size):
_print += "#" * self.__size
if i != (self.__size - 1):
_print += "\n"
print(_print)