0% found this document useful (0 votes)
23 views

Main Py

This Python code welcomes the user and asks if they want to calculate the area or perimeter of different shapes. It then prompts the user to select a shape and enter the appropriate dimensions or measurements. Based on the inputs, it will calculate and print the area or perimeter of the selected shape using functions defined in other modules.

Uploaded by

mrundisputable10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Main Py

This Python code welcomes the user and asks if they want to calculate the area or perimeter of different shapes. It then prompts the user to select a shape and enter the appropriate dimensions or measurements. Based on the inputs, it will calculate and print the area or perimeter of the selected shape using functions defined in other modules.

Uploaded by

mrundisputable10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PYTHON CODE

print("------------------------------------ Welcome my Master


------------------------------------\n")
print("Today I will help you find areas and perimeters")
x = input("What do you want to calculate: area or perimeter? ")
print("The shapes which you can input are (circle, rectangle, square,
triangle, rhombus, semicircle, parallelogram)")
print(" \n")

shapes = ["circle", "rectangle", "square", "triangle", "rhombus",


"semicircle", "parallelogram"]

if x.lower() == "perimeter":
from Perimeter import *

shape = input("For which shape do you want to calculate the


perimeter? ")

if shape.lower() == "circle":
p = input("Enter the radius of the Circle: ")
if p.isdigit():
print("Valid input")
print("Perimeter of the circle is", perimeter_circle(int(p)))
else:
print("Invalid input. Please enter an integer only.")
elif shape.lower() == "rectangle":
l = int(input("Enter the length of the rectangle: "))
b = int(input("Enter the breadth of the rectangle: "))
print("Perimeter of Rectangle is", perimeter_rectangle(l, b))

elif shape.lower() == "square":


s = input("Enter the side of the square: ")
if s.isdigit():
print("Valid input")
print("Perimeter of the Square is", perimeter_square(int(s)))
else:
print("Invalid input. Please enter an integer only.")

elif shape.lower() == "triangle":


q = int(input("Enter the First side of the triangle: "))
w = int(input("Enter the Second side of the triangle: "))
e = int(input("Enter the Third side of the triangle: "))
print("Perimeter of the Triangle is", perimeter_triangle(q, w, e))

elif shape.lower() == "rhombus":


r = input("Enter the side of the Rhombus: ")
if r.isdigit():
print("Valid input")
print("Perimeter of the Rhombus is",
perimeter_rhombus(int(r)))
else:
print("Invalid input. Please enter an integer only.")

elif shape.lower() == "semicircle":


t = input("Enter the radius of the Semicircle: ")
if t.isdigit():
print("Valid input")
print("Perimeter of the Semicircle is",
perimeter_semicircle(int(t)))
else:
print("Invalid input. Please enter an integer only.")

elif shape.lower() == "parallelogram":


y = int(input("Enter the First side of Parallelogram: "))
u = int(input("Enter the Second side of Parallelogram: "))
print("Perimeter of the Parallelogram is",
perimeter_parallelogram(y, u))
else:
print("Shape not found")

elif x.lower() == "area":


from area import *
shape = input("For which shape do you want to calculate the area?
")

if shape.lower() == "circle":
v = int(input("Enter the radius of the Circle: "))
print("Area of the circle is", area_circle(v))
elif shape.lower() == "rectangle":
m = int(input("Enter the length of the rectangle: "))
n = int(input("Enter the breadth of the rectangle: "))
print("Area of Rectangle is", area_rectangle(m,n))

elif shape.lower() == "square":


k = input("Enter the side of the square: ")
if k.isdigit():
print("Valid input")
print("Area of the Square is", area_square(int(k)))
else:
print("Invalid input. Please enter an integer only.")
elif shape.lower() == "triangle":
k1 = int(input("Enter the base of the triangle: "))
k2 = int(input("Enter the height of the triangle: "))
print("Area of the Triangle is", area_triangle(k1, k2))

elif shape.lower() == "rhombus":


y1 = int(input("Enter the diagnol 1 of the rhombus: "))
y2 = int(input("Enter the diagnol 2 of the rhombus: "))
print("Area of the Rhombus is",area_rhombus(y1, y2))

elif shape.lower() == "semicircle":


t1 = input("Enter the radius of the Semicircle: ")
if t1.isdigit():
print("Valid input")
print("Area of the Semicircle is", area_semicircle(int(t1)))
else:
print("Invalid input. Please enter an integer only.")

elif shape.lower() == "parallelogram":


y1 = int(input("Enter the First side of Parallelogram: "))
u1 = int(input("Enter the Second side of Parallelogram: "))
print("Area of the Parallelogram is", area_parallelogram(y1, u1))

else:
print("Shape not found")

else:
print("Invalid input. Please enter 'area' or 'perimeter'.")

You might also like