ุงู†ุชู‚ู„ ู„ู„ู…ุญุชูˆู‰
Robo EgyptRobo Egypt
โ˜ฐ Course contents
Robo Python: home
0. Lab tour1
1. The start5
2. Variables and input5
3. Conditions5
4. Loops5
5. Lists4
6. Functions4
7. Drawing with the turtle3
8. The project: the guess-the-number game3
9. Strings in depth1
10. Dictionaries (dict)3
11. Randomness and errors3
12. Classes and objects (class)2
13. Pro drawing and charts3
14. The final project: the quiz game2

๐Ÿ› ๏ธ Section project: a spiral

Section 7: Drawing with the turtleLesson 7.3 ยท โฑ 10 min
๐ŸŽฏ Project goal
A coloured spiral: every line is longer than the one before.
๐Ÿ A spiral
import turtle
t = turtle.Turtle()
t.speed(0)
t.pensize(2)
for i in range(100):
    t.color(["#5B3DF5", "#1E7BFF", "#18B37E", "#FF8A1F"][i % 4])
    t.forward(i * 2)
    t.left(91)
The turtle drawing in Robo Python๐Ÿ Open the code in Robo Python โ†—

๐Ÿ“Œ Another example: a square spiral

Every side is a little longer than the one before.

๐Ÿ A square spiral
import turtle
t = turtle.Turtle()
t.speed(0)
t.color("blue")
for i in range(60):
    t.forward(i * 4)
    t.left(90)
๐Ÿ Open the code in Robo Python โ†—
In Robo Python
In Robo Python
โœ๏ธ Practise
Challenge: change 91 to 89 or 121. What happens to the shape?
โœ๏ธ Practise here in the lessonor open the lab in a new page โ†—

๐ŸŽฏ Challenge yourself

Easy

A spiral turning 91 instead of 90: it becomes twisted.

๐Ÿ‘€ Show the solution
๐Ÿ Solution
import turtle
t = turtle.Turtle()
t.speed(0)
for i in range(80):
    t.forward(i * 3)
    t.left(91)
๐Ÿ Open the code in Robo Python โ†—
In Robo Python
In Robo Python

Result: a twisted spiral.

Medium

A spiral of circles: 36 circles, turning 10 each time.

๐Ÿ‘€ Show the solution
๐Ÿ Solution
import turtle
t = turtle.Turtle()
t.speed(0)
t.color("purple")
for i in range(36):
    t.circle(70)
    t.left(10)
๐Ÿ Open the code in Robo Python โ†—
In Robo Python
In Robo Python

Result: a flower of circles.

Hard

A spiral with colours taking turns.

๐Ÿ‘€ Show the solution
๐Ÿ Solution
import turtle
t = turtle.Turtle()
t.speed(0)
colors = ["red", "orange", "green", "blue"]
for i in range(100):
    t.color(colors[i % 4])
    t.forward(i * 2)
    t.left(91)
๐Ÿ Open the code in Robo Python โ†—
In Robo Python
In Robo Python

Result: a coloured spiral.

Finished the lesson? Mark it so your progress counts.