Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
new_proj
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
logesh.n
new_proj
Commits
a2ffcd4e
Commit
a2ffcd4e
authored
Jan 24, 2023
by
logesh.n
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added area.py file
parent
6f2fb51f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
10 deletions
+59
-10
app.py
+16
-8
scripts/core/handlers/area.py
+27
-0
scripts/core/handlers/perimeter.py
+16
-2
No files found.
app.py
View file @
a2ffcd4e
print
(
"Calculate perimeter and area of the following shapes given in the list"
)
print
(
"
\n
1) Rectangle
\n
2) Square
\n
3) Circle
\n
"
)
option
=
input
(
"Type ''pr'' to calculate the perimeter of rectangle and ''ar'' to calculate the area of the rectangle
\n
"
"Type ''ps'' to calculate the perimeter of square and ''as'' to calculate the area of the"
"square
\n
Type ''pc'' to calculate the perimeter of circle and ''ac'' to calculate the area of the circle "
">> "
)
option
=
input
(
"Type '''pr''' to calculate perimeter of the shapes and '''ar''' to calculate area of the shapes >> "
)
if
option
==
"pr"
:
print
(
"
\n
Do you want to c
alculate the perimeter of Rectangle?
"
)
print
(
"
\n
Do you want to c
ontinue?
"
)
confirm
=
(
input
(
"type ''y'' to continue and ''n'' to stop >> "
))
if
confirm
==
"y"
:
length
=
int
(
input
(
"
\n
enter the length of the rectangle >> "
))
breadth
=
int
(
input
(
"enter the breadth of the rectangle >> "
))
radius
=
int
(
input
(
"enter the radius of the rectangle
>> "
))
length
=
int
(
input
(
"
\n
enter the length of the rectangle
/square/circle (zero for circle)
>> "
))
breadth
=
int
(
input
(
"enter the breadth of the rectangle
/square/circle (zero for circle)
>> "
))
radius
=
int
(
input
(
"enter the radius of the rectangle
/square/circle (it is zero in rectangle and square)
>> "
))
elif
confirm
==
"n"
:
print
(
"try again"
)
elif
option
==
"ar"
:
print
(
"
\n
Do you want to continue?"
)
confirm
=
(
input
(
"type ''y'' to continue and ''n'' to stop >> "
))
if
confirm
==
"y"
:
length
=
int
(
input
(
"
\n
enter the length of the rectangle/square/circle (zero for circle) >> "
))
breadth
=
int
(
input
(
"enter the breadth of the rectangle/square/circle (zero for circle) >> "
))
radius
=
int
(
input
(
"enter the radius of the rectangle/square/circle (it is zero in rectangle and square)>> "
))
elif
confirm
==
"n"
:
print
(
"try again"
)
scripts/core/handlers/area.py
View file @
a2ffcd4e
from
scripts.constants.constant
import
PI
from
app
import
length
,
breadth
,
radius
class
Area
:
def
__init__
(
self
,
length1
,
breadth1
,
radius1
):
self
.
length1
=
length1
self
.
breadth1
=
breadth1
self
.
radius1
=
radius1
def
rectangle
(
Area
):
final_Area
=
2
*
(
Area
.
length1
+
Area
.
breadth1
)
print
(
"Perimeter of the Rectangle >> "
,
final_Area
)
def
square
(
Area
):
final_Area
=
(
4
*
length
)
print
(
"Perimeter of the Square >> "
,
final_Area
)
def
circle
(
Area
):
final_Area
=
(
2
*
PI
*
radius
)
print
(
"Perimeter of the Circle >> "
,
final_Area
)
area
=
Area
(
length
,
breadth
,
radius
)
area
.
rectangle
()
area
.
circle
()
area
.
square
()
scripts/core/handlers/perimeter.py
View file @
a2ffcd4e
from
scripts.constants.constant
import
PI
from
app
import
length
,
breadth
,
radius
from
scripts.core.handlers.area
import
Area
class
Perimeter
:
...
...
@@ -7,10 +8,23 @@ class Perimeter:
self
.
length1
=
length1
self
.
breadth1
=
breadth1
self
.
radius1
=
radius1
def
rectangle
(
Perimeter
):
final_perimeter
=
2
*
(
Perimeter
.
length1
+
Perimeter
.
breadth1
)
print
(
"Perimeter of the Rectangle >> "
,
final_perimeter
)
def
square
(
Perimeter
):
final_perimeter
=
(
4
*
length
)
print
(
"Perimeter of the Square >> "
,
final_perimeter
)
def
circle
(
Perimeter
):
final_perimeter
=
(
2
*
PI
*
radius
)
print
(
"Perimeter of the Circle >> "
,
final_perimeter
)
perimeter
=
Perimeter
(
length
,
breadth
,
radius
)
perimeter
.
rectangle
()
perimeter
.
square
()
perimeter
.
circle
()
peri_of_circle
=
Perimeter
(
length
,
breadth
,
radius
)
peri_of_circle
.
rectangle
()
print
(
Area
)
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