A small geometry toolkit built with Python and OOP. It defines a Rectangle class and a Square class that inherits from it, with methods to compute area, perimeter, diagonal, draw the shape, and check how many shapes fit inside another.
🎯 Built to practice inheritance, method overriding, and class design.
- Create
Rectangle(width, height) andSquare(side) objects - Compute area, perimeter, and diagonal
- Modify dimensions via setter methods
- Render shapes using
*characters (get_picture) - Calculate how many shapes fit inside another (
get_amount_inside) - Clean
__str__object representation
Classes & Objects · Inheritance · Method Overriding · Math · String Formatting · Loops
| Class / Method | Description |
|---|---|
Rectangle |
Base shape with width & height |
Square(Rectangle) |
Inherits Rectangle, single side |
get_area() / get_perimeter() |
Geometry calculations |
get_diagonal() |
Pythagorean diagonal |
get_picture() |
ASCII drawing of the shape |
get_amount_inside(shape) |
Fits count of one shape in another |
# Requires Python 3.8+
python polygon_calculator.py- Using inheritance in Python
- Overriding methods in subclasses
- Structuring programs around classes
- Applying math formulas in code
- Add
Circle/Triangleclasses - Unit tests with
pytest - CLI to accept user dimensions