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 # inherited Exception class
class TestException(Exception): class TestException(Exception):
pass pass
...@@ -9,7 +10,7 @@ class Circle: ...@@ -9,7 +10,7 @@ class Circle:
def area_circle(self): def area_circle(self):
try: try:
area = 3.14 * self.radius * self.radius area = PI * self.radius * self.radius
return area return area
except TestException: except TestException:
print("\nException Occurred\n") print("\nException Occurred\n")
...@@ -18,7 +19,7 @@ class Circle: ...@@ -18,7 +19,7 @@ class Circle:
def perimeter_circle(self): def perimeter_circle(self):
try: try:
perimeter = 2 * 3.14 * self.radius perimeter = 2 * PI * self.radius
return perimeter return perimeter
except TestException: except TestException:
print("\nException Occurred\n") print("\nException Occurred\n")
......
"""import shapes from package 'shape'.""" """import shapes from package 'shape'."""
from shape.rectangle import Rect from scripts.core.handlers.rectangle import Rect
from shape.square import Square from scripts.core.handlers.square import Square
from shape.circle import Circle from scripts.core.handlers.circle import Circle
# iterating variable def shape():
i = 1 # iterating variable
while i == 1: i = 1
while i == 1:
print("----------Area & Perimeter----------\n" print("----------Area & Perimeter----------\n"
"1.Rectangle\n" "1.Rectangle\n"
"2.Circle\n" "2.Circle\n"
"3.Square\n" "3.Square\n"
"4.Enter 0 to exit\n") "4.Exit\n")
choice = int(input("Enter the choice: ")) choice = int(input("Enter the choice: "))
if choice == 1: if choice == 1:
rect_length = float(input( rect_length = float(input(
...@@ -41,6 +42,6 @@ while i == 1: ...@@ -41,6 +42,6 @@ while i == 1:
square_inst.area_square()) square_inst.area_square())
print("Perimeter of Square: ", print("Perimeter of Square: ",
square_inst.perimeter_square()) square_inst.perimeter_square())
elif choice == 0: elif choice == 4:
i = 0 i = 0
# Exit if ch # 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