Lesson 3: Any shape
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
The 360 rule
- To draw a shape with
nequal sides, turn360 / ndegrees at each corner. - Square: 360 / 4 = 90. Triangle: 360 / 3 = 120.
Words for this lesson
| Word | Meaning |
|---|---|
| polygon | a closed shape with straight sides |
| hexagon | a polygon with 6 sides |
| variable | a name for a value, like sides = 6 |
English
Change one number
import turtle
sides = 5
for i in range(sides):
turtle.forward(80)
turtle.left(360 / sides)
- Change
sidesto 6, 8 or 10. The loop does the rest.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Draw a hexagon: 6 equal sides of 80 steps. Use a loop and the 360 rule.
点击“运行”查看此处输出。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Draw an octagon (8 sides) with sides of 50 steps. A stop sign has this shape.
点击“运行”查看此处输出。