FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sample/draw_from_file.py at main · truongthanhtam212/python-sample · GitHub
truongthanhtam212
/
python-sample
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sample
/
draw_from_file.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (25 loc) · 818 Bytes
Breadcrumbs
python-sample
/
draw_from_file.py
Copy path
File metadata and controls
26 lines (25 loc) · 818 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
18
19
20
21
22
23
24
25
26
"""
Goal: A program that reads drawing instructions from a file and uses them along with the existing draw function
to draw spirals.
"""
from
turtle
import
*
def
draw_spiral
(
c
,
arc
,
r
,
growth
,
size
):
color
(
c
)
pensize
(
size
)
for
a
in
range
(
arc
):
down
()
circle
(
r
,
90
)
r
=
r
+
growth
up
()
def
draw_from_file
(
filename
):
with
open
(
filename
)
as
target
:
for
i
in
target
:
rows
=
i
.
split
(
","
)
for
a
,
part
in
enumerate
(
rows
):
rows
[
a
]
=
part
.
strip
()
colour
=
rows
[
0
]
arc
=
int
(
rows
[
1
])
radius
=
int
(
rows
[
2
])
radius_growth
=
float
(
rows
[
3
])
pen_weight
=
int
(
rows
[
4
])
draw_spiral
(
colour
,
arc
,
radius
,
radius_growth
,
pen_weight
)
Back
|
FazBrowse Home
|
New Git URL