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.
לחץ על הרץ כדי לראות את התוצא כאן.