FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/classes/circle_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
/
circle_user.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (18 loc) · 1.02 KB
Breadcrumbs
programmingWithPythonCode
/
classes
/
circle_user.py
Copy path
File metadata and controls
22 lines (18 loc) · 1.02 KB
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
18
19
20
21
22
"""Examples for using our class :class:`Circle`."""
from
circle
import
Circle
# Our new class `Circle`.
from
point
import
Point
# Our very first class ever: `Point`.
from
shape
import
Shape
# Our base class `Shape`.
circ
:
Circle
=
Circle
(
Point
(
2
,
3
),
5
)
# Create a new circle instance.
print
(
f" center: (
{
circ
.
center
.
x
}
,
{
circ
.
center
.
y
}
)"
)
print
(
f" radius:
{
circ
.
radius
}
"
)
print
(
f" perimeter:
{
circ
.
perimeter
()
}
"
)
print
(
f" area:
{
circ
.
area
()
}
"
)
# Do some instance tests.
print
(
f" isinstance(circ, Circle):
{
isinstance
(
circ
,
Circle
)
}
"
)
print
(
f" isinstance(circ, Shape):
{
isinstance
(
circ
,
Shape
)
}
"
)
print
(
f" isinstance(circ, object):
{
isinstance
(
circ
,
object
)
}
"
)
# Explore the class hierarchy.
print
(
f" issubclass(Circle, Shape):
{
issubclass
(
Circle
,
Shape
)
}
"
)
print
(
f" issubclass(Shape, Circle):
{
issubclass
(
Shape
,
Circle
)
}
"
)
print
(
f" issubclass(Shape, object):
{
issubclass
(
Shape
,
object
)
}
"
)
print
(
f"issubclass(Circle, object):
{
issubclass
(
Circle
,
object
)
}
"
)
Back
|
FazBrowse Home
|
New Git URL