/* jquery */ /* jquery accordion style*/ /* jquery init */

5 January 2013

Raspberry Pi Python: Turtle Patterns

Exploring the interactive world of Turtle Graphics on your Raspberry Pi is easy with Python's 'turtle' module.

Here's a short Python program to create a pattern with coloured circles:

from turtle import *

pensize(5)

for i in range(4):
   for c in ["red","green","blue"]:
      pencolor(c)
      circle(100)
      right(30)

exitonclick()

Create a new Geany file, enter the Python code, save it as turtle-patterns.py and execute the program. After you've seen it run modify the code to experiment with different pen sizes, colour names and circle diameters.

Visit my Raspberry Pi page for news, reviews, advice and tutorials.

No comments: