Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

polygon-area-calculator

Shape Creator is a Python program that lets users create and analyze Rectangles and Squares using OOP concepts. It calculates area, perimeter, and diagonal, and displays an ASCII art representation of the shape. With clean class design and smart input handling, it’s ideal for learning inheritance and geometry in Python.

Features

Dynamic Shape Creation – Automatically identifies whether the input forms a Rectangle or a Square. Mathematical Insights – Calculates:

Area

Perimeter

Diagonal length

ASCII Visualization – Prints a visual representation of the shape using the * symbol (within size limits). Smart Input Handling – Automatically handles missing height input for squares. Clean OOP Design – Uses inheritance to extend the Rectangle class into a Square class for reusability and simplicity.

Project Structure shape_creator/ │ ├── shape_creator.py # Main program file (contains Rectangle & Square classes) └── README.md # Project documentation (this file)

Classes Overview:-

Rectangle

Attributes: width, height

Methods: get_area(), get_perimeter(), get_diagonal(), get_picture(), get_amount_inside()

Square (Rectangle)

Inherits from Rectangle

Methods: set_side(), set_width(), set_height() (ensures both sides stay equal)

How to Run?

Clone this repository:

git clone https://github.com/yourusername/shape-creator.git cd shape-creator

Run the program:

python shape_creator.py

Enter the width and optionally the height when prompted.

If you press Enter after width, it creates a Square.

Otherwise, it creates a Rectangle.

Example Output Shape Creator — Powered by Python

Enter width: 5 Enter height (press Enter if same as width): 3

Created a Rectangle(width=5.0, height=3.0) Area: 15.00 Perimeter: 16.00 Diagonal: 5.83

Picture:




Concepts Demonstrated:- Object-Oriented Programming (OOP) Class Inheritance & Method Overriding Input Validation ASCII Graphics in Python

Future Enhancements:- Add support for more shapes (Triangle, Circle, etc.) Implement graphical visualization using tkinter or matplotlib Include unit testing with unittest or pytest

About

Shape Creator is a Python program that lets users create and analyze Rectangles and Squares using OOP concepts. It calculates area, perimeter, and diagonal, and displays an ASCII art representation of the shape. With clean class design and smart input handling, it’s ideal for learning inheritance and geometry in Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages