Commit 3723a5c3 by arjun.b

project structure updated

parent 97245889
from scripts.services.index import shape
shape()
from scripts.constants.const import *
class myException(Exception): class myException(Exception):
pass pass
class Circle: class Circle:
def __init__(self, radius): def __init__(self, radius):
self.radius = radius self.radius = radius
def area(self): def area(self):
try: try:
return 3.14 * self.radius * self.radius return pi * self.radius * self.radius
except myException: except myException:
print("exception occurred") print("exception occurred")
def perimetr(self): def perimetr(self):
try: try:
return 2 * 3.14 * self.radius return 2 * pi * self.radius
except myException: except myException:
print("exception occurred") print("exception occurred")
from shape.rectangle import Rect from scripts.core.handlers.rectangle import Rect
from shape.Circle import Circle from scripts.core.handlers.Circle import Circle
from shape.square import Square from scripts.core.handlers.square import Square
i = 1
while i == 1: def shape():
print("enter the choice \n1.area and perimeter of rectangle\n" i = 1
"2.area and perimeter of circle\n" while i == 1:
"3.area and perimeter of square\n" print("enter the choice \n1.area and perimeter of rectangle\n"
"4.exit") "2.area and perimeter of circle\n"
choice = int(input("enter your choice")) "3.area and perimeter of square\n"
if choice == 1: "4.exit")
length = float(input("enter the length of the rectangle")) choice = int(input("enter your choice"))
width = float(input("enter the width of the rectangle")) if choice == 1:
obj_rect = Rect(length, width) # create the object of the class Rect length = float(input("enter the length of the rectangle"))
print("area of rectangle=", obj_rect.area()) width = float(input("enter the width of the rectangle"))
print("perimeter of rectangle=", obj_rect.perimetr()) obj_rect = Rect(length, width) # create the object of the class Rect
elif choice == 2: print("area of rectangle=", obj_rect.area())
# initializing the radius of the circle print("perimeter of rectangle=", obj_rect.perimetr())
radius = float(input("enter the radius")) elif choice == 2:
obj_cir = Circle(radius) # create the object of the class Circle # initializing the radius of the circle
print("area of circle=", obj_cir.area(), "\n", "perimeter of circle", obj_cir.perimetr()) radius = float(input("enter the radius"))
# initializing the side of the square obj_cir = Circle(radius) # create the object of the class Circle
elif choice == 3: print("area of circle=", obj_cir.area(), "\n", "perimeter of circle", obj_cir.perimetr())
side = float(input("enter the side of the square")) # initializing the side of the square
obj_sqr = Square(side) # create the object of the class Square elif choice == 3:
print("area of Square=", obj_sqr.area(), "\n", "perimeter of square", obj_sqr.perimtr()) side = float(input("enter the side of the square"))
elif choice == 4: obj_sqr = Square(side) # create the object of the class Square
i = 0 print("area of Square=", obj_sqr.area(), "\n", "perimeter of square", obj_sqr.perimtr())
elif choice == 4:
i = 0
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