Jason Cemra Jason Cemra - 1 year ago 124
Python Question

How was this Python Turtle graphic made?

My friend showed me this amazing image that she made using Python's inbuilt Turtle module and challenged me to find out how it was made. She gave me one hint: the image was produced with 10 lines of code.

10 Line Turtle Graphic

From my question you probably already know that I have no clue. I've tried a whole heap of things, but I don't know how she made a filled in circle with such detailed patterns in only 10 lines. I've given up on figuring it out myself, and my friend won't tell me, so anyone who can produce 10 lines that make a similar image gets all the credit for figuring it out :P

Note: I'm not sure if this is appropriate for StackOverflow, so I'm happy to ask elsewhere (let me know), but this was made using Python code, so I thought someone on a programming forum might have the experience to work it out.

Answer Source

Here is what I believe your looking for:

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> t = turtle.Pen()
>>> for i in range(1000):
...     t.forward(100)
...     t.backward(100)
...     t.left(79)


enter image description here

It is a miniature example of the output you showed in your question. Basicly the way that is works is that each time the turtle pen goes forward and comes back, the pen turns. This is repeated multiple times, to create those 'detailed patterns'. Also, your friend may have mislead you a bit, as this is much shorter than ten lines.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download