Skip to content

Commit

Permalink
My square
Browse files Browse the repository at this point in the history
  • Loading branch information
99omniaashraf committed Mar 15, 2024
1 parent a6520ac commit 8682850
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions 0x01-challenge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x01-challenge
33 changes: 33 additions & 0 deletions 0x01-challenge/square.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 8682850

Please sign in to comment.