Python Turtle Programming for Kids
You can let your kids learn their first coding lesson with a simple setup. Kids can learn how to write their first computer program through Python Turtle Graphics.
Installing Python: Standalone, Python Shell, IDE
To learn Python coding, you will need a program to type in your codes. You have several options.
The first option is you can download and install the standalone program "Python Turtle." which was developed by Ram Rachum.
You can download Python Turtle from:
The second option is to download and install Python on your Windows or Linux machine. Once it is set up, you can write codes through the Python Shell. The Python Shell is a window which looks similar to the command lines (of your Windows or Linux machine). You will access the "Turtle" module through Python Shell.
You can download Python from:
The third option is that on top of Python Shell, you are to download and install one of the IDEs. IDE stands for integrated development environment. One of the IDEs which is specifically developed for Python is Jetbrains' Pycharm.
You can download Pycharm from:
If you have installed the simple program "Python Turtle", then you are not required to install the conventional Python Shell or the IDE. But you are limited to only code and run very simple Python Turtle graphics programs.
The First Python Lession
I am going to demonstrate the Python Turtle Graphics lessons through the Python Shell in most cases. Start the Python Shell, and enter the 3 lines.
The first line is to import the Turtle module. The second line we assign "gordon" (an instance of turtle) a pen to draw. This turtle is the main target of our program. The third line we give it a "turtle" shape.
After the first 3 lines, we get our turtle printed at the center of our screen. Python Turtle Graphics is a drawing program, and the screen is where our turtle will draw.
Note the turtle is currently heading to the right (i.e. east). Let's draw a straight line of length 100 by moving the turtle forward, and then turn the turtle 90 degrees to the left (i.e. counter-clockwise).
Let's draw a square.
You repeated typing "forward(100)" and "left(90)" 4 times each, but you did not have to do so.
Now clear your screen and start over again.
With a "for" loop, you will achieve identical result. Note the last 2 lines (i.e. "forward(100)" and "left(90)") must be indented for your program to work.
Now make the turtle draw two squares which do not touch each other.
This line increases the line width to 3.
This line picks up the pen, so the turtle will not draw when moving.
This line puts down the pen, so the turtle will start drawing again when moving.
Now make the turtle draw multiple squares where all the squares are on different positions and have different sizes. Note we have achieved this by using a function.
We import Python's random number generation module.
This line changes the line color to blue.
We speed up the drawing.
We declare function "square" which has a single parameter "size".
We move the turtle to co-ordirnates x and y. Each iteration of the "for" loop changes the values of x and y. This way, the turtle is taken to different positions (e.g. x, y) to draw squares.
Let's draw a different shape (e.g. Circle). Now draw 3 circles. The first circle has a diameter of 50 (i.e. diameter x 2 = 100). The second circle is half the size of the first circle. The third circle falls to the bottom half of the screen.
Now we draw a maze.
Lastly, we draw a spring (i.e. spiral) using multiple circles with different sizes.