-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5-square.py
executable file
·39 lines (32 loc) · 988 Bytes
/
5-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
#!/usr/bin/python3
"""Defining a class Square"""
class Square:
"""Defining a class Squate"""
def __init__(self, size):
"""Initialize a new square.
Args:
size (int): Size of new Square.
"""
self.__size = size
@property
def size(self):
"""Function retrieves a Square"""
return(self.__size)
@size.setter
def size(self, value):
"""Set properties of new Square"""
if not isinstance(value, int):
raise TypeError("size must be an integer")
elif value < 0:
raise ValueError("size must be >= 0")
self.__size = value
def area(self):
"""Return area of Square"""
return(self.__size * self.__size)
def my_print(self):
"""Prints output in stdout"""
for i in range(0, self.__size):
[print("#", end="") for j in range(self.__size)]
print("")
if self.__size == 0:
print("")