Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
training
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arjun.b
training
Commits
c6914ce5
Commit
c6914ce5
authored
Jan 17, 2023
by
arjun.b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assignment 1
parent
ea54cc90
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
.idea/calculator.iml
+2
-1
index.py
+1
-1
shape/rectangle.py
+5
-7
No files found.
.idea/calculator.iml
View file @
c6914ce5
...
@@ -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
index.py
View file @
c6914ce5
...
@@ -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
...
...
shape/rectangle.py
View file @
c6914ce5
class
m
yException
(
Exception
):
class
M
yException
(
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
m
yException
:
except
M
yException
:
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment