From 8682850e0d7f2fa54467da9c13ad6b16cf206672 Mon Sep 17 00:00:00 2001 From: 99omniaashraf Date: Fri, 15 Mar 2024 14:17:29 -0700 Subject: [PATCH] My square --- 0x01-challenge/README.md | 1 + 0x01-challenge/square.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 0x01-challenge/README.md create mode 100644 0x01-challenge/square.py diff --git a/0x01-challenge/README.md b/0x01-challenge/README.md new file mode 100644 index 0000000..e5d8fc9 --- /dev/null +++ b/0x01-challenge/README.md @@ -0,0 +1 @@ +0x01-challenge diff --git a/0x01-challenge/square.py b/0x01-challenge/square.py new file mode 100644 index 0000000..f7bbf21 --- /dev/null +++ b/0x01-challenge/square.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +""" Module for square class""" + + +class Square(): + """ Square class """ + width = 0 + height = 0 + + def __init__(self, *args, **kwargs): + """ Instantiation of class """ + for key, value in kwargs.items(): + setattr(self, key, value) + + def area_of_my_square(self): + """ Area of the square """ + return self.width * self.height + + def permiter_of_my_square(self): + """ Perimeter of my square """ + return (self.width * 2) + (self.height * 2) + + def __str__(self): + """ Printable representation """ + return "{}/{}".format(self.width, self.height) + + +if __name__ == "__main__": + """ Create a square object """ + s = Square(width=12, height=9) + print(s) + print(s.area_of_my_square()) + print(s.permiter_of_my_square())