Commit c593a00d by ajil.k

added assignment1

parents
# Default ignored files
/shelf/
/workspace.xml
<?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
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E302" />
<option value="E501" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredNames">
<list>
<option value="sum" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<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"?>
<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/Shapes.iml" filepath="$PROJECT_DIR$/.idea/Shapes.iml" />
</modules>
</component>
</project>
\ No newline at end of file
"""import shapes from package 'shape'."""
from shape.rectangle import Rect
from shape.square import Square
from shape.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
class Circle:
def __init__(self, radius):
self.radius = radius
def area_circle(self):
area = 3.14 * self.radius * self.radius
return area
def perimeter_circle(self):
perimeter = 2 * 3.14 * self.radius
return perimeter
class Rect:
def __init__(self, length, breadth):
self.length = length
self.breadth = breadth
def area_rect(self):
area = self.length * self.breadth
return area
def perimeter_rect(self):
perimeter = 2 * (self.length + self.breadth)
return perimeter
class Square:
def __init__(self, side):
self.side = side
def area_square(self):
area = self.side * self.side
return area
def perimeter_square(self):
perimeter = 4 * self.side
return perimeter
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