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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
36 deletions
+51
-36
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
+35
-30
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
# inheriting exception class
class
Check
(
Exception
):
class
Check
(
Exception
):
pass
pass
...
@@ -16,7 +19,7 @@ class Area(Circle):
...
@@ -16,7 +19,7 @@ class Area(Circle):
def
circle_area
(
self
):
def
circle_area
(
self
):
try
:
try
:
print
(
3.14
*
self
.
radius
*
self
.
radius
)
print
(
"area="
,
constant_values
.
pi
*
self
.
radius
*
self
.
radius
)
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
...
@@ -29,6 +32,6 @@ class Perimeter(Circle):
...
@@ -29,6 +32,6 @@ class Perimeter(Circle):
def
circle_perimeter
(
self
):
def
circle_perimeter
(
self
):
try
:
try
:
print
(
2
*
3.14
*
self
.
radius
)
print
(
"perimeter="
,
2
*
constant_values
.
pi
*
self
.
radius
)
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
s
hapes
/rectangle.py
→
s
cripts/core/handler
/rectangle.py
View file @
fad8e324
...
@@ -16,7 +16,7 @@ class Area(Rectangle):
...
@@ -16,7 +16,7 @@ class Area(Rectangle):
def
rectangle_area
(
self
):
def
rectangle_area
(
self
):
try
:
try
:
print
(
self
.
length
*
self
.
breadth
)
print
(
"area"
,
self
.
length
*
self
.
breadth
)
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
...
@@ -28,6 +28,6 @@ class Perimeter(Rectangle):
...
@@ -28,6 +28,6 @@ class Perimeter(Rectangle):
def
rectangle_perimeter
(
self
):
def
rectangle_perimeter
(
self
):
try
:
try
:
print
(
2
*
(
self
.
length
+
self
.
breadth
))
print
(
"perimeter="
,
2
*
(
self
.
length
+
self
.
breadth
))
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
s
hapes
/square.py
→
s
cripts/core/handler
/square.py
View file @
fad8e324
...
@@ -15,7 +15,7 @@ class Area(Square):
...
@@ -15,7 +15,7 @@ class Area(Square):
def
square_area
(
self
):
def
square_area
(
self
):
try
:
try
:
print
(
self
.
length
*
self
.
length
)
print
(
"area="
,
self
.
length
*
self
.
length
)
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
...
@@ -27,6 +27,6 @@ class Perimeter(Square):
...
@@ -27,6 +27,6 @@ class Perimeter(Square):
def
square_perimeter
(
self
):
def
square_perimeter
(
self
):
try
:
try
:
print
(
self
.
length
*
4
)
print
(
"perimeter="
,
self
.
length
*
4
)
except
Check
:
except
Check
:
print
(
"
\n
exception occurred"
)
print
(
"
\n
exception occurred"
)
main.py
→
scripts/servieces/
main.py
View file @
fad8e324
from
shapes
import
square
# importing modules
from
shapes
import
rectangle
from
scripts.core.handler
import
circle
,
rectangle
,
square
from
shapes
import
circle
while
True
:
def
shapes
():
i
=
1
# selecting shape by user
while
i
==
1
:
print
(
"1.square
\n
2.rectangle
\n
3.circle
\n
"
)
# selecting shape by user
shape
=
int
(
input
(
"enter your choice
\n
"
))
print
(
"1.square
\n
2.rectangle
\n
3.circle
\n
0.Exit"
)
# Exception raise for wrong choice
shape
=
int
(
input
(
"enter your choice
\n
"
))
if
shape
>
4
or
shape
<
0
:
# calling for calculation of square
raise
Exception
(
"invalid choice of shape"
)
if
shape
==
1
:
side
=
float
(
input
(
"enter side length"
))
# calling for calculation
square
.
Area
(
side
)
.
square_area
()
if
shape
==
1
:
square
.
Perimeter
(
side
)
.
square_perimeter
()
side
=
float
(
input
(
"enter side length"
))
square
.
Area
(
side
)
.
square_area
()
# calling for calculation of rectangle
square
.
Perimeter
(
side
)
.
square_perimeter
()
elif
shape
==
2
:
elif
shape
==
2
:
length
=
float
(
input
(
"enter the length"
))
length
=
float
(
input
(
"enter the length"
))
breadth
=
float
(
input
(
"enter the breadth"
))
breadth
=
float
(
input
(
"enter the breadth"
))
rectangle
.
Area
(
length
,
breadth
)
.
rectangle_area
()
rectangle
.
Area
(
length
,
breadth
)
.
rectangle_area
()
rectangle
.
Perimeter
(
length
,
breadth
)
.
rectangle_perimeter
()
rectangle
.
Perimeter
(
length
,
breadth
)
.
rectangle_perimeter
()
elif
shape
==
3
:
radius
=
float
(
input
(
"enter the radius"
))
# calling for calculation of circle
circle
.
Area
(
20
)
.
circle_area
()
circle
.
Perimeter
(
20
)
.
circle_perimeter
()
elif
shape
==
3
:
radius
=
float
(
input
(
"enter the radius"
))
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