Commit c6914ce5 by arjun.b

Assignment 1

parent ea54cc90
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -6,7 +6,7 @@ length = float(input("enter the length of the rectangle")) ...@@ -6,7 +6,7 @@ length = float(input("enter the length of the rectangle"))
width = float(input("enter the width of the rectangle")) width = float(input("enter the width of the rectangle"))
obj_rect = Rect(length, width) # create the object of the class Rect obj_rect = Rect(length, width) # create the object of the class Rect
print("area of rectangle=",obj_rect.area()) print("area of rectangle=",obj_rect.area())
print("perimeter of rectangle=",obj_rect.perimetr) print("perimeter of rectangle=",obj_rect.perimetr())
# initializing the radius of the circle # initializing the radius of the circle
radius = float(input("enter the radius")) radius = float(input("enter the radius"))
obj_cir = Circle(radius) # create the object of the class Circle obj_cir = Circle(radius) # create the object of the class Circle
......
class myException(Exception): class MyException(Exception):
pass pass
...@@ -10,13 +10,12 @@ class Rect: ...@@ -10,13 +10,12 @@ class Rect:
def area(self): def area(self):
try: try:
return self.length * self.width return self.length * self.width
except myException: except MyException:
print("exception occurred") print("exception occurred")
def perimetr(self): def perimetr(self):
try: try:
return 2 * (self.length + self.width) c = self.length * 2 + self.width * 2
except myException: return c
except MyException:
print("exception occurred") print("exception occurred")
finally:
print("-----------")
\ 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