Commit 7e5ccd97 by ajil.k

updated with new project structure.

parent 4dff9579
from scripts.services.main import shape
shape()
\ No newline at end of file
from scripts.constants.values import PI
# inherited Exception class
class TestException(Exception):
pass
......@@ -9,7 +10,7 @@ class Circle:
def area_circle(self):
try:
area = 3.14 * self.radius * self.radius
area = PI * self.radius * self.radius
return area
except TestException:
print("\nException Occurred\n")
......@@ -18,7 +19,7 @@ class Circle:
def perimeter_circle(self):
try:
perimeter = 2 * 3.14 * self.radius
perimeter = 2 * PI * self.radius
return perimeter
except TestException:
print("\nException Occurred\n")
......
"""import shapes from package 'shape'."""
from shape.rectangle import Rect
from shape.square import Square
from shape.circle import Circle
from scripts.core.handlers.rectangle import Rect
from scripts.core.handlers.square import Square
from scripts.core.handlers.circle import Circle
# iterating variable
i = 1
while i == 1:
print("----------Area & Perimeter----------\n"
"1.Rectangle\n"
"2.Circle\n"
"3.Square\n"
"4.Enter 0 to exit\n")
choice = int(input("Enter the choice: "))
if choice == 1:
rect_length = float(input(
"Enter the length: "))
rect_breadth = float(input(
"Enter the breadth: "))
# creating object of Rect
rect_inst = Rect(rect_length, rect_breadth)
print("Area of Rectangle: ",
rect_inst.area_rect())
print("Perimeter of Rectangle: ",
rect_inst.perimeter_rect())
elif choice == 2:
circle_radius = float(input(
"Enter the radius: "))
# creating object of Circle
circle_inst = Circle(circle_radius)
print("Area of Circle: ",
circle_inst.area_circle())
print("\nCircumference of Circle: ",
circle_inst.perimeter_circle())
elif choice == 3:
square_side = float(input(
"Enter the side length: "))
# creating object of Square
square_inst = Square(square_side)
print("Area of Square: ",
square_inst.area_square())
print("Perimeter of Square: ",
square_inst.perimeter_square())
elif choice == 0:
i = 0
# Exit if ch
def shape():
# iterating variable
i = 1
while i == 1:
print("----------Area & Perimeter----------\n"
"1.Rectangle\n"
"2.Circle\n"
"3.Square\n"
"4.Exit\n")
choice = int(input("Enter the choice: "))
if choice == 1:
rect_length = float(input(
"Enter the length: "))
rect_breadth = float(input(
"Enter the breadth: "))
# creating object of Rect
rect_inst = Rect(rect_length, rect_breadth)
print("Area of Rectangle: ",
rect_inst.area_rect())
print("Perimeter of Rectangle: ",
rect_inst.perimeter_rect())
elif choice == 2:
circle_radius = float(input(
"Enter the radius: "))
# creating object of Circle
circle_inst = Circle(circle_radius)
print("Area of Circle: ",
circle_inst.area_circle())
print("\nCircumference of Circle: ",
circle_inst.perimeter_circle())
elif choice == 3:
square_side = float(input(
"Enter the side length: "))
# creating object of Square
square_inst = Square(square_side)
print("Area of Square: ",
square_inst.area_square())
print("Perimeter of Square: ",
square_inst.perimeter_square())
elif choice == 4:
i = 0
# Exit if choice is 4
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