Mensurator | A Python Program Which Will Calculate Perimeter Or Area For You
This is a program which calculates the Perimeter or the Area of the 4 basic shape i.e Rectangle,Triangle,Square and Circle by Aditya Shrivastava
The User has the power to select the mode (Perimeter, Area) and the Shape and give input to the values according to the shape chosen.
It is written in Python 3.8.0
Enjoy...
Source Code:
The following code files are required to be in the same folder:
script.py
# Mensurator Program # Made By Aditya Shrivastava # COPYRIGHT Aditya Shrivastava 2020-3020 #-----------------------------Importation----------------------------------------- from perimeter import perimeterFinder from area import areaFinder # ----------------------------Welcome Screen--------------------------------------- myProgram = True print("---------------------------------------------------------------------------------------") print("Welcome To Mensurator") print("---------------------") while myProgram == True: #------------------------------Select Mode--------------------------------------------- print("Select Mode") print("---------------------") print("'p' for Perimter ") print("'a' for Area ") print("'e' for exit ") print("---------------------") userMode = input("Enter Mode: ") userMode = userMode.lower() #--------------------------If Else For Mode if userMode == 'p' : perimeterFinder() elif userMode == 'a': areaFinder() elif userMode == 'e': exit() else: print("INVALID INPUT")
perimeter.py
from perimterShape import sqrPerimeter from perimterShape import rectPerimeter from perimterShape import triPerimeter from perimterShape import cirPerimeter def perimeterFinder(): print("---------------------") print("Enter 's' for square") print("Enter 'r' for rectangle") print("Enter 't' for triangle") print("Enter 'c' for circle") print("---------------------") userShape = input("Enter Your Shape: ") userShape = userShape.lower() print("---------------------") if userShape == 's': sqrPerimeter(float(input("Enter Value Of Side: "))) elif userShape == 'r': rectPerimeter(float(input("Enter Lenght Value: ")), float(input("Enter Bredth Value: "))) elif userShape == 't': triPerimeter(float(input("Enter Value Of First Side: ")) ,float(input("Enter Value Of Second Side: ")) ,float(input("Enter Value Of Third Side: ")) ) elif userShape == 'c': cirPerimeter(float(input("Enter Radius: ")))
perimeterShape.py
def sqrPerimeter(side): print("---------------------") print("---------------------------------The Perimter Is: " , side*4 , " ----------------------------------") print("---------------------") return sqrPerimeter def rectPerimeter(leng, bred): print("---------------------") print("---------------------------------The Perimter Is: " , 2 * (leng+bred), " ----------------------------------") print("---------------------") return rectPerimeter def triPerimeter(side1, side2, side3): print("---------------------") print("---------------------------------The Perimter Is: " , side1 + side2 + side3, " ----------------------------------") print("---------------------") return triPerimeter def cirPerimeter(r): print("---------------------") print("---------------------------------The Perimter Is: " , 2 * 3.14 * r, " ----------------------------------") print("---------------------") return cirPerimeter
area.py
from areaShape import sqrArea from areaShape import rectArea from areaShape import triArea from areaShape import cirArea def areaFinder(): print("---------------------") print("Enter 's' for square") print("Enter 'r' for rectangle") print("Enter 't' for triangle") print("Enter 'c' for circle") print("---------------------") userShape = input("Enter Your Shape: ") userShape = userShape.lower() print("---------------------") if userShape == 's': sqrArea(float(input("Enter Value Of Side: "))) elif userShape == 'r': rectArea(float(input("Enter Length Value: ")), float(input("Enter Bredth Value: "))) elif userShape == 't': triArea(float(input("Enter Value Of Base: ")) ,float(input("Enter Value Of Height: "))) elif userShape == 'c': cirArea(float(input("Enter Radius: ")))
areaShape.py
def sqrArea(side): print("---------------------") print("---------------------------------The Area Is: " , side*side , " ----------------------------------") print("---------------------") return sqrArea def rectArea(leng, bred): print("---------------------") print("---------------------------------The Area Is: " , leng*bred, " ----------------------------------") print("---------------------") return rectArea def triArea(base, height): print("---------------------") print("---------------------------------The Area Is: " , 1/2 * (base*height), " ----------------------------------") print("---------------------") return triArea def cirArea(r): print("---------------------") print("---------------------------------The Area Is: " ,3.14 * r * 2, " ----------------------------------") print("---------------------") return cirArea
thank you for visiting this page.
Download this program :
*PLEASE USE FOR EDUCATIONAL PURPOSE ONLY
Aditya Shrivastava | MyProgramArchives
Comments
Post a Comment