FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/classes/shape_user.py at main · thomasWeise/programmingWithPythonCode · GitHub
thomasWeise
programmingWithPythonCode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
classes
/
shape_user.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (13 loc) · 694 Bytes
Breadcrumbs
programmingWithPythonCode
/
classes
/
shape_user.py
Copy path
File metadata and controls
17 lines (13 loc) · 694 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Examples for using the different :class:`Shape` classes."""
from
circle
import
Circle
# Our new class `Circle`.
from
point
import
Point
# Our very first class ever: `Point`.
from
rectangle
import
Rectangle
# Our new class `Rectangle`.
from
triangle
import
Triangle
# Our new class `Triangle`.
from
shape
import
Shape
# Our base class `Shape`.
shapes
:
list
[
Shape
]
=
[
# We create list of shapes.
Circle
(
Point
(
2
,
3
),
5
),
Rectangle
(
Point
(
2
,
3
),
Point
(
3
,
5
)),
Triangle
(
Point
(
2
,
3
),
Point
(
3
,
5
),
Point
(
7
,
4
)),
]
for
s
in
shapes
:
# Print shape classes, areas, and perimeters.
print
(
f"
{
type
(
s
)
}
instance with A=
{
s
.
area
()
}
and P=
{
s
.
perimeter
()
}
"
)
Back
|
FazBrowse Home
|
New Git URL