From 673bef97d3aae28cb6ab58560690c390e5842bf8 Mon Sep 17 00:00:00 2001 From: john mokaya Date: Mon, 22 Jul 2024 14:15:20 +0300 Subject: [PATCH] Update square.py --- square.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/square.py b/square.py index 6d05328..32f6d98 100755 --- a/square.py +++ b/square.py @@ -1,28 +1,23 @@ -#!/usr/bin/python3 - -class square(): - - width = 0 - height = 0 - +class Square: - def __init__(self, *args, **kwargs): - for key, value in kwargs.items(): - setattr(self, key, value) + def __init__(self, width=0, height=0): + self.width = width + self.height = height def area_of_my_square(self): """ Area of the square """ return self.width * self.width - def PermiterOfMySquare(self): - return (self.width * 2) + (self.height * 2) + def perimeter_of_my_square(self): + """ Perimeter of the square """ + return self.width * 4 def __str__(self): return "{}/{}".format(self.width, self.height) if __name__ == "__main__": - s = square(width=12, height=9) + s = Square(width=12, height=9) print(s) print(s.area_of_my_square()) - print(s.PermiterOfMySquare()) + print(s.perimeter_of_my_square())