Commit fad8e324 by mohammed.shibili

altered coding standard

parent f2ebfddb
from scripts.servieces.main import shapes
print("program for finding area and perimeter of shapes")
shapes()
python 3.9.13
\ No newline at end of file
from scripts.constants import constant_values
# inheriting exception class
class Check(Exception):
pass
......@@ -16,7 +19,7 @@ class Area(Circle):
def circle_area(self):
try:
print(3.14 * self.radius * self.radius)
print("area=", constant_values.pi * self.radius * self.radius)
except Check:
print("\n exception occurred")
......@@ -29,6 +32,6 @@ class Perimeter(Circle):
def circle_perimeter(self):
try:
print(2 * 3.14 * self.radius)
print("perimeter=", 2 * constant_values.pi * self.radius)
except Check:
print("\n exception occurred")
......@@ -16,7 +16,7 @@ class Area(Rectangle):
def rectangle_area(self):
try:
print(self.length * self.breadth)
print("area", self.length * self.breadth)
except Check:
print("\n exception occurred")
......@@ -28,6 +28,6 @@ class Perimeter(Rectangle):
def rectangle_perimeter(self):
try:
print(2 * (self.length + self.breadth))
print("perimeter=", 2 * (self.length + self.breadth))
except Check:
print("\n exception occurred")
......@@ -15,7 +15,7 @@ class Area(Square):
def square_area(self):
try:
print(self.length * self.length)
print("area=", self.length * self.length)
except Check:
print("\n exception occurred")
......@@ -27,6 +27,6 @@ class Perimeter(Square):
def square_perimeter(self):
try:
print(self.length * 4)
print("perimeter=", self.length * 4)
except Check:
print("\n exception occurred")
from shapes import square
from shapes import rectangle
from shapes import circle
# importing modules
from scripts.core.handler import circle, rectangle, square
while True:
def shapes():
i = 1
while i == 1:
# selecting shape by user
print("1.square \n 2.rectangle \n 3.circle \n")
print("1.square \n 2.rectangle \n 3.circle \n 0.Exit")
shape = int(input("enter your choice\n"))
# Exception raise for wrong choice
if shape > 4 or shape < 0:
raise Exception("invalid choice of shape")
# calling for calculation
# calling for calculation of square
if shape == 1:
side = float(input("enter side length"))
square.Area(side).square_area()
square.Perimeter(side).square_perimeter()
# calling for calculation of rectangle
elif shape == 2:
length = float(input("enter the length"))
breadth = float(input("enter the breadth"))
rectangle.Area(length, breadth).rectangle_area()
rectangle.Perimeter(length, breadth).rectangle_perimeter()
# calling for calculation of circle
elif shape == 3:
radius = float(input("enter the radius"))
circle.Area(20).circle_area()
circle.Perimeter(20).circle_perimeter()
circle.Area(radius).circle_area()
circle.Perimeter(radius).circle_perimeter()
elif shape == 0:
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