To Calculate the Area of 2D shapes
The 2D shape Area Calculator is basic python script enables us to easily calculate Areas of 2D shapes.
- This code is used find area of respective 2D shape by giving specified inputs. (Eg: If our 2D Shape is circle.To find Area of cirlce required input will be it's radius)
- Libraries Imported:
math
- Choose one option from the following 2D shape for which you need to find area
Circle
Triangle
Square
Rectangle
Parallelogram
Trapezium
Ellipse
- Enter required inputs properly as follows:
- If
circle
is opted then, required input isradius
- If
Triangle
is opted then, required inputs arebase
height
orsides
- If
Square
is opted then, required input isside
- If
Rectangle
is opted then, required inputs arelength
andbreadth
- If
Parallelogram
is opted then, required inputs arelength
andbreadth
- If
Trapezium
is opted then, required arebases
andheight
- If
Ellipse
is opted then, required inputs areaxis
- If
- Based on the shape opted by the user, it executes that particular block of code and takes input from user and gives Area as output.
- Download " 2D_shapes_area_calculator.py " file.
- Run "2D_shapes_area_calculator.py" file.
- Find the area of any 2D shape by entering required inputs properly.
- This program is made of simple "if - elif - else" syntax.
- Start of the program every 2D shape is assigned a particular option. i.e.,
print("Please choose one of the following option to find Areas of 2D shape: \n1.Circle \n2.Triangle \n3.Square \n4.Rectangle \n5.Parallelogram \n6.Trapezium \n7.Ellipse")
- The
if
statement checks for condition and if this condition evaluates to True,then the statements inside the if block will be executed. - If
if
condition evaluates to False, then flow of program control goes toelif
statement and if this condition evaluates to True,then the statements inside the elif block will be executed. - The flow of control goes to
else
condition when theelif
condition evaluates to False. - For more information on import statements, refer to "requirements.txt".
- Area of Circle
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfCircle.png
- Area of Triangle
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfTriangle1.png
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfTriangle1.png
- Area of Square
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfSquare.png
- Area of Rectangle
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfRectangle.png
- Area of Parallelogram
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfParallelogram.png
- Area of Trapezium
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfTrapezium.png
- Area of Ellipse
Path link: https://github.com/DurgaSai-16/Awesome_Python_Scripts/blob/main/BasicPythonScripts/The%202D%20Shape%20Area%20Calculator/Images/AreaOfEllipse.png