Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Assignment-1
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
Assignment-1
Commits
3723a5c3
Commit
3723a5c3
authored
Jan 17, 2023
by
arjun.b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project structure updated
parent
97245889
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
30 deletions
+41
-30
app.py
+3
-0
scripts/constants/const.py
+1
-0
scripts/core/handlers/Circle.py
+7
-2
scripts/core/handlers/rectangle.py
+0
-0
scripts/core/handlers/square.py
+0
-0
scripts/services/index.py
+30
-28
No files found.
app.py
0 → 100644
View file @
3723a5c3
from
scripts.services.index
import
shape
shape
()
scripts/constants/const.py
0 → 100644
View file @
3723a5c3
pi
=
3.14
s
hape
/Circle.py
→
s
cripts/core/handlers
/Circle.py
View file @
3723a5c3
from
scripts.constants.const
import
*
class
myException
(
Exception
):
pass
class
Circle
:
def
__init__
(
self
,
radius
):
self
.
radius
=
radius
def
area
(
self
):
try
:
return
3.14
*
self
.
radius
*
self
.
radius
return
pi
*
self
.
radius
*
self
.
radius
except
myException
:
print
(
"exception occurred"
)
def
perimetr
(
self
):
try
:
return
2
*
3.14
*
self
.
radius
return
2
*
pi
*
self
.
radius
except
myException
:
print
(
"exception occurred"
)
s
hape
/rectangle.py
→
s
cripts/core/handlers
/rectangle.py
View file @
3723a5c3
File moved
s
hape
/square.py
→
s
cripts/core/handlers
/square.py
View file @
3723a5c3
File moved
index.py
→
scripts/services/
index.py
View file @
3723a5c3
from
s
hape
.rectangle
import
Rect
from
s
hape
.Circle
import
Circle
from
s
hape
.square
import
Square
from
s
cripts.core.handlers
.rectangle
import
Rect
from
s
cripts.core.handlers
.Circle
import
Circle
from
s
cripts.core.handlers
.square
import
Square
i
=
1
while
i
==
1
:
print
(
"enter the choice
\n
1.area and perimeter of rectangle
\n
"
"2.area and perimeter of circle
\n
"
"3.area and perimeter of square
\n
"
"4.exit"
)
choice
=
int
(
input
(
"enter your choice"
))
if
choice
==
1
:
length
=
float
(
input
(
"enter the length of the rectangle"
))
width
=
float
(
input
(
"enter the width of the rectangle"
))
obj_rect
=
Rect
(
length
,
width
)
# create the object of the class Rect
print
(
"area of rectangle="
,
obj_rect
.
area
())
print
(
"perimeter of rectangle="
,
obj_rect
.
perimetr
())
elif
choice
==
2
:
# initializing the radius of the circle
radius
=
float
(
input
(
"enter the radius"
))
obj_cir
=
Circle
(
radius
)
# create the object of the class Circle
print
(
"area of circle="
,
obj_cir
.
area
(),
"
\n
"
,
"perimeter of circle"
,
obj_cir
.
perimetr
())
# initializing the side of the square
elif
choice
==
3
:
side
=
float
(
input
(
"enter the side of the square"
))
obj_sqr
=
Square
(
side
)
# create the object of the class Square
print
(
"area of Square="
,
obj_sqr
.
area
(),
"
\n
"
,
"perimeter of square"
,
obj_sqr
.
perimtr
())
elif
choice
==
4
:
i
=
0
def
shape
():
i
=
1
while
i
==
1
:
print
(
"enter the choice
\n
1.area and perimeter of rectangle
\n
"
"2.area and perimeter of circle
\n
"
"3.area and perimeter of square
\n
"
"4.exit"
)
choice
=
int
(
input
(
"enter your choice"
))
if
choice
==
1
:
length
=
float
(
input
(
"enter the length of the rectangle"
))
width
=
float
(
input
(
"enter the width of the rectangle"
))
obj_rect
=
Rect
(
length
,
width
)
# create the object of the class Rect
print
(
"area of rectangle="
,
obj_rect
.
area
())
print
(
"perimeter of rectangle="
,
obj_rect
.
perimetr
())
elif
choice
==
2
:
# initializing the radius of the circle
radius
=
float
(
input
(
"enter the radius"
))
obj_cir
=
Circle
(
radius
)
# create the object of the class Circle
print
(
"area of circle="
,
obj_cir
.
area
(),
"
\n
"
,
"perimeter of circle"
,
obj_cir
.
perimetr
())
# initializing the side of the square
elif
choice
==
3
:
side
=
float
(
input
(
"enter the side of the square"
))
obj_sqr
=
Square
(
side
)
# create the object of the class Square
print
(
"area of Square="
,
obj_sqr
.
area
(),
"
\n
"
,
"perimeter of square"
,
obj_sqr
.
perimtr
())
elif
choice
==
4
:
i
=
0
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