Commit a2ffcd4e by logesh.n

added area.py file

parent 6f2fb51f
print("Calculate perimeter and area of the following shapes given in the list") print("Calculate perimeter and area of the following shapes given in the list")
print("\n1) Rectangle\n2) Square\n3) Circle\n") print("\n1) Rectangle\n2) Square\n3) Circle\n")
option = input("Type ''pr'' to calculate the perimeter of rectangle and ''ar'' to calculate the area of the rectangle\n" option = input("Type '''pr''' to calculate perimeter of the shapes and '''ar''' to calculate area of the shapes >> ")
"Type ''ps'' to calculate the perimeter of square and ''as'' to calculate the area of the"
"square\nType ''pc'' to calculate the perimeter of circle and ''ac'' to calculate the area of the circle "
">> ")
if option == "pr": if option == "pr":
print("\nDo you want to calculate the perimeter of Rectangle? ") print("\nDo you want to continue?")
confirm = (input("type ''y'' to continue and ''n'' to stop >> ")) confirm = (input("type ''y'' to continue and ''n'' to stop >> "))
if confirm == "y": if confirm == "y":
length = int(input("\nenter the length of the rectangle >> ")) length = int(input("\nenter the length of the rectangle/square/circle (zero for circle) >> "))
breadth = int(input("enter the breadth of the rectangle >> ")) breadth = int(input("enter the breadth of the rectangle/square/circle (zero for circle) >> "))
radius = int(input("enter the radius of the rectangle >> ")) radius = int(input("enter the radius of the rectangle/square/circle (it is zero in rectangle and square)>> "))
elif confirm == "n": elif confirm == "n":
print("try again") print("try again")
elif option == "ar":
print("\nDo you want to continue?")
confirm = (input("type ''y'' to continue and ''n'' to stop >> "))
if confirm == "y":
length = int(input("\nenter the length of the rectangle/square/circle (zero for circle) >> "))
breadth = int(input("enter the breadth of the rectangle/square/circle (zero for circle) >> "))
radius = int(input("enter the radius of the rectangle/square/circle (it is zero in rectangle and square)>> "))
elif confirm == "n":
print("try again")
from scripts.constants.constant import PI
from app import length, breadth, radius
class Area:
def __init__(self, length1, breadth1, radius1):
self.length1 = length1
self.breadth1 = breadth1
self.radius1 = radius1
def rectangle(Area):
final_Area = 2 * (Area.length1 + Area.breadth1)
print("Perimeter of the Rectangle >> ", final_Area)
def square(Area):
final_Area = (4 * length)
print("Perimeter of the Square >> ", final_Area)
def circle(Area):
final_Area = (2 * PI * radius)
print("Perimeter of the Circle >> ", final_Area)
area = Area(length, breadth, radius)
area.rectangle()
area.circle()
area.square()
from scripts.constants.constant import PI from scripts.constants.constant import PI
from app import length, breadth, radius from app import length, breadth, radius
from scripts.core.handlers.area import Area
class Perimeter: class Perimeter:
...@@ -7,10 +8,23 @@ class Perimeter: ...@@ -7,10 +8,23 @@ class Perimeter:
self.length1 = length1 self.length1 = length1
self.breadth1 = breadth1 self.breadth1 = breadth1
self.radius1 = radius1 self.radius1 = radius1
def rectangle(Perimeter): def rectangle(Perimeter):
final_perimeter = 2 * (Perimeter.length1 + Perimeter.breadth1) final_perimeter = 2 * (Perimeter.length1 + Perimeter.breadth1)
print("Perimeter of the Rectangle >> ", final_perimeter) print("Perimeter of the Rectangle >> ", final_perimeter)
def square(Perimeter):
final_perimeter = (4 * length)
print("Perimeter of the Square >> ", final_perimeter)
def circle(Perimeter):
final_perimeter = (2 * PI * radius)
print("Perimeter of the Circle >> ", final_perimeter)
perimeter = Perimeter(length, breadth, radius)
perimeter.rectangle()
perimeter.square()
perimeter.circle()
peri_of_circle = Perimeter(length, breadth, radius) print(Area)
peri_of_circle.rectangle()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment