Turtle graphics is a popular way for introducing programming. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.

Turtle graphic allows you to give commands to ’turtle’ and draw intricate shapes.

TurtlePython can be used to introduce someone to main concepts in programming (python program structrure, variables, functions, …).

For experienced programmers it gives way to create, express themselfs.

install

If you have operating system based on Ubuntu 22 install turtle python library with :

sudo apt-get install python3-tk
pip install PythonTurtle

example 1

To create ’turtle star’ write and run python program : star-pic

from turtle import *
color('red', 'yellow')
bgcolor('black')
begin_fill()
while True:
    forward(200)
    left(170)
    if abs(pos()) < 1:
        break
end_fill()
done()

example 2

Another example is spiral, it is produced by program: spiral-pic

import turtle
colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
t = turtle.Pen()
turtle.bgcolor('black')
for x in range(60):
    t.pencolor(colors[x%6])
    t.width(x//100 + 1)
    t.forward(x)
    t.left(59)

turtle.mainloop()

Turtle library offers more functions than shown in above examples, you can read about them in documentation.

Strongly encurage you to try it, play and have fun with it.

sources