Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
area-and-perimeter-of-shapes
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
mohammed.shibili
area-and-perimeter-of-shapes
Commits
fad8e324
Commit
fad8e324
authored
Jan 17, 2023
by
mohammed.shibili
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
altered coding standard
parent
f2ebfddb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
19 deletions
+34
-19
app.py
+5
-0
requirements
+2
-0
scripts/core/handler/circle.py
+5
-2
scripts/core/handler/rectangle.py
+2
-2
scripts/core/handler/square.py
+2
-2
scripts/servieces/main.py
+18
-13
No files found.
app.py
0 → 100644
View file @
fad8e324
from
scripts.servieces.main
import
shapes
print
(
"program for finding area and perimeter of shapes"
)
shapes
()
requirements
0 → 100644
View file @
fad8e324
python 3.9.13
\ No newline at end of file
s
hapes
/circle.py
→
s
cripts/core/handler
/circle.py
View file @
fad8e324
from
scripts.constants
import
constant_values
# inheriting exception class
class
Check
(
Exception
):
pass
...
...
@@ -16,7 +19,7 @@ class Area(Circle):
def
circle_area
(
self
):
try
:
print
(
3.14
*
self
.
radius
*
self
.
radius
)
print
(
"area="
,
constant_values
.
pi
*
self
.
radius
*
self
.
radius
)
except
Check
:
print
(
"
\n
exception occurred"
)
...
...
@@ -29,6 +32,6 @@ class Perimeter(Circle):
def
circle_perimeter
(
self
):
try
:
print
(
2
*
3.14
*
self
.
radius
)
print
(
"perimeter="
,
2
*
constant_values
.
pi
*
self
.
radius
)
except
Check
:
print
(
"
\n
exception occurred"
)
s
hapes
/rectangle.py
→
s
cripts/core/handler
/rectangle.py
View file @
fad8e324
...
...
@@ -16,7 +16,7 @@ class Area(Rectangle):
def
rectangle_area
(
self
):
try
:
print
(
self
.
length
*
self
.
breadth
)
print
(
"area"
,
self
.
length
*
self
.
breadth
)
except
Check
:
print
(
"
\n
exception occurred"
)
...
...
@@ -28,6 +28,6 @@ class Perimeter(Rectangle):
def
rectangle_perimeter
(
self
):
try
:
print
(
2
*
(
self
.
length
+
self
.
breadth
))
print
(
"perimeter="
,
2
*
(
self
.
length
+
self
.
breadth
))
except
Check
:
print
(
"
\n
exception occurred"
)
s
hapes
/square.py
→
s
cripts/core/handler
/square.py
View file @
fad8e324
...
...
@@ -15,7 +15,7 @@ class Area(Square):
def
square_area
(
self
):
try
:
print
(
self
.
length
*
self
.
length
)
print
(
"area="
,
self
.
length
*
self
.
length
)
except
Check
:
print
(
"
\n
exception occurred"
)
...
...
@@ -27,6 +27,6 @@ class Perimeter(Square):
def
square_perimeter
(
self
):
try
:
print
(
self
.
length
*
4
)
print
(
"perimeter="
,
self
.
length
*
4
)
except
Check
:
print
(
"
\n
exception occurred"
)
main.py
→
scripts/servieces/
main.py
View file @
fad8e324
from
shapes
import
square
from
shapes
import
rectangle
from
shapes
import
circle
# importing modules
from
scripts.core.handler
import
circle
,
rectangle
,
square
while
True
:
def
shapes
():
i
=
1
while
i
==
1
:
# selecting shape by user
print
(
"1.square
\n
2.rectangle
\n
3.circle
\n
"
)
print
(
"1.square
\n
2.rectangle
\n
3.circle
\n
0.Exit
"
)
shape
=
int
(
input
(
"enter your choice
\n
"
))
# Exception raise for wrong choice
if
shape
>
4
or
shape
<
0
:
raise
Exception
(
"invalid choice of shape"
)
# calling for calculation
# calling for calculation of square
if
shape
==
1
:
side
=
float
(
input
(
"enter side length"
))
square
.
Area
(
side
)
.
square_area
()
square
.
Perimeter
(
side
)
.
square_perimeter
()
# calling for calculation of rectangle
elif
shape
==
2
:
length
=
float
(
input
(
"enter the length"
))
breadth
=
float
(
input
(
"enter the breadth"
))
rectangle
.
Area
(
length
,
breadth
)
.
rectangle_area
()
rectangle
.
Perimeter
(
length
,
breadth
)
.
rectangle_perimeter
()
# calling for calculation of circle
elif
shape
==
3
:
radius
=
float
(
input
(
"enter the radius"
))
circle
.
Area
(
20
)
.
circle_area
()
circle
.
Perimeter
(
20
)
.
circle_perimeter
()
circle
.
Area
(
radius
)
.
circle_area
()
circle
.
Perimeter
(
radius
)
.
circle_perimeter
()
elif
shape
==
0
:
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