If you are using the standard installation of Python from python.org which comes with the IDLE editor, there are some exciting demonstrations of the power of the turtle module available at the click of a mouse.
The turtle module is hugely useful for learning about and teaching programming, and also great fun. It provides a way to express computational concepts in a visual form and provides easy-to-interpret feedback on what is happening in a program.
To get an idea of what is possible with Python and the Turtle module, select the help menu in IDLE and click on
Turtle Demo. Then choose one of the examples from the menu and off you go!
Many of the examples use straightforward procedural code so should be fairly eady to understand – for example
yinyang. Others make use object oriented programming (
Nim for example), which is great if you are learning or teaching A Level Computer Science.
One great thing about the demos is that you can copy the code and adapt it to your own needs.
Here is the code for
from turtle import * def yin(radius, color1, color2): width(3) color("black", color1) begin_fill() circle(radius/2., 180) circle(radius, 180) left(180) circle(-radius/2., 180) end_fill() left(90) up() forward(radius*0.35) right(90) down() color(color1, color2) begin_fill() circle(radius*0.15) end_fill() left(90) up() backward(radius*0.35) down() left(90) def main(): reset() yin(200, "black", "white") yin(200, "white", "black") ht() return "Done!" if __name__ == '__main__': main() mainloop()
Plenty of bits in there you can make use of I expect.
The Turtle module in Python is awesome. I hope you have fun with it.