Commit bce4d5ae by rakesh.pv

shapes task3

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/kl_task3.iml" filepath="$PROJECT_DIR$/.idea/kl_task3.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
from scripts.services.main import shape
shape()
\ No newline at end of file
pi=3.14
\ No newline at end of file
from scripts.constants.values import pi
class TestException(Exception):
pass
class Circle:
def _init_(self, radius):
self.radius = radius
def area_circle(self):
try:
area = pi * self.radius * self.radius
return area
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
def perimeter_circle(self):
try:
perimeter = 2 * pi * self.radius
return perimeter
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
\ No newline at end of file
class TestException(Exception):
pass
class Rect:
def _init_(self, length, breadth):
self.length = length
self.breadth = breadth
def area_rect(self):
try:
area = self.length * self.breadth
return area
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
def perimeter_rect(self):
try:
perimeter = 2 * (self.length + self.breadth)
return perimeter
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
\ No newline at end of file
class TestException(Exception):
pass
class Square:
def _init_(self, side):
self.side = side
def area_square(self):
try:
area = self.side * self.side
return area
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
def perimeter_square(self):
try:
perimeter = 4 * self.side
return perimeter
except TestException:
print("\nException Occurred\n")
finally:
print("stopped")
\ No newline at end of file
from scripts.core.handlers.rectangle import Rect
from scripts.core.handlers.square import Square
from scripts.core.handlers.circle import Circle
def shape():
i = 1
while i == 1:
print("\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: "))
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: "))
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: "))
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
\ No newline at end of file
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