Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
Internship-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
ajil.k
Internship-Training
Commits
7e5ccd97
Commit
7e5ccd97
authored
Jan 17, 2023
by
ajil.k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated with new project structure.
parent
4dff9579
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
46 deletions
+53
-46
app.py
+4
-0
scripts/constants/values.py
+1
-0
scripts/core/handlers/__init__.py
+0
-0
scripts/core/handlers/circle.py
+3
-2
scripts/core/handlers/rectangle.py
+0
-0
scripts/core/handlers/square.py
+0
-0
scripts/services/main.py
+45
-44
No files found.
app.py
0 → 100644
View file @
7e5ccd97
from
scripts.services.main
import
shape
shape
()
\ No newline at end of file
scripts/constants/values.py
0 → 100644
View file @
7e5ccd97
PI
=
3.14
s
hape
/__init__.py
→
s
cripts/core/handlers
/__init__.py
View file @
7e5ccd97
File moved
s
hape
/circle.py
→
s
cripts/core/handlers
/circle.py
View file @
7e5ccd97
from
scripts.constants.values
import
PI
# inherited Exception class
# inherited Exception class
class
TestException
(
Exception
):
class
TestException
(
Exception
):
pass
pass
...
@@ -9,7 +10,7 @@ class Circle:
...
@@ -9,7 +10,7 @@ class Circle:
def
area_circle
(
self
):
def
area_circle
(
self
):
try
:
try
:
area
=
3.14
*
self
.
radius
*
self
.
radius
area
=
PI
*
self
.
radius
*
self
.
radius
return
area
return
area
except
TestException
:
except
TestException
:
print
(
"
\n
Exception Occurred
\n
"
)
print
(
"
\n
Exception Occurred
\n
"
)
...
@@ -18,7 +19,7 @@ class Circle:
...
@@ -18,7 +19,7 @@ class Circle:
def
perimeter_circle
(
self
):
def
perimeter_circle
(
self
):
try
:
try
:
perimeter
=
2
*
3.14
*
self
.
radius
perimeter
=
2
*
PI
*
self
.
radius
return
perimeter
return
perimeter
except
TestException
:
except
TestException
:
print
(
"
\n
Exception Occurred
\n
"
)
print
(
"
\n
Exception Occurred
\n
"
)
...
...
s
hape
/rectangle.py
→
s
cripts/core/handlers
/rectangle.py
View file @
7e5ccd97
File moved
s
hape
/square.py
→
s
cripts/core/handlers
/square.py
View file @
7e5ccd97
File moved
main.py
→
scripts/services/
main.py
View file @
7e5ccd97
"""import shapes from package 'shape'."""
"""import shapes from package 'shape'."""
from
s
hape
.rectangle
import
Rect
from
s
cripts.core.handlers
.rectangle
import
Rect
from
s
hape
.square
import
Square
from
s
cripts.core.handlers
.square
import
Square
from
s
hape
.circle
import
Circle
from
s
cripts.core.handlers
.circle
import
Circle
# iterating variable
def
shape
():
i
=
1
# iterating variable
while
i
==
1
:
i
=
1
print
(
"----------Area & Perimeter----------
\n
"
while
i
==
1
:
"1.Rectangle
\n
"
print
(
"----------Area & Perimeter----------
\n
"
"2.Circle
\n
"
"1.Rectangle
\n
"
"3.Square
\n
"
"2.Circle
\n
"
"4.Enter 0 to exit
\n
"
)
"3.Square
\n
"
choice
=
int
(
input
(
"Enter the choice: "
))
"4.Exit
\n
"
)
if
choice
==
1
:
choice
=
int
(
input
(
"Enter the choice: "
))
rect_length
=
float
(
input
(
if
choice
==
1
:
"Enter the length: "
))
rect_length
=
float
(
input
(
rect_breadth
=
float
(
input
(
"Enter the length: "
))
"Enter the breadth: "
))
rect_breadth
=
float
(
input
(
# creating object of Rect
"Enter the breadth: "
))
rect_inst
=
Rect
(
rect_length
,
rect_breadth
)
# creating object of Rect
print
(
"Area of Rectangle: "
,
rect_inst
=
Rect
(
rect_length
,
rect_breadth
)
rect_inst
.
area_rect
())
print
(
"Area of Rectangle: "
,
print
(
"Perimeter of Rectangle: "
,
rect_inst
.
area_rect
())
rect_inst
.
perimeter_rect
())
print
(
"Perimeter of Rectangle: "
,
elif
choice
==
2
:
rect_inst
.
perimeter_rect
())
circle_radius
=
float
(
input
(
elif
choice
==
2
:
"Enter the radius: "
))
circle_radius
=
float
(
input
(
# creating object of Circle
"Enter the radius: "
))
circle_inst
=
Circle
(
circle_radius
)
# creating object of Circle
print
(
"Area of Circle: "
,
circle_inst
=
Circle
(
circle_radius
)
circle_inst
.
area_circle
())
print
(
"Area of Circle: "
,
print
(
"
\n
Circumference of Circle: "
,
circle_inst
.
area_circle
())
circle_inst
.
perimeter_circle
())
print
(
"
\n
Circumference of Circle: "
,
elif
choice
==
3
:
circle_inst
.
perimeter_circle
())
square_side
=
float
(
input
(
elif
choice
==
3
:
"Enter the side length: "
))
square_side
=
float
(
input
(
# creating object of Square
"Enter the side length: "
))
square_inst
=
Square
(
square_side
)
# creating object of Square
print
(
"Area of Square: "
,
square_inst
=
Square
(
square_side
)
square_inst
.
area_square
())
print
(
"Area of Square: "
,
print
(
"Perimeter of Square: "
,
square_inst
.
area_square
())
square_inst
.
perimeter_square
())
print
(
"Perimeter of Square: "
,
elif
choice
==
0
:
square_inst
.
perimeter_square
())
i
=
0
elif
choice
==
4
:
# Exit if ch
i
=
0
# Exit if choice is 4
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