Play with Python

You can do some funny staff with Python. it simply amuses.
Issue this command in your Linux terminal:
sudo apt-get install python3-tk
It will install the necessary packages. Now it is time to write some code:


import turtle

pen = turtle.Pen()
colors =['red', 'orange', 'yellow', 'blue', 'pink', 'white', 'purple', 'green', 'light blue']
sides = 8

for x in range(360):
    pen.pencolor(colors[x % sides])
    pen.forward(x * sides / 3 + x)
    pen.left(360 / sides + 1)
    pen.width(x * sides / 100)

If you run this program, you will see something like this:

Python with turtle module

Python with turtle module


3 thoughts on “Play with Python

  1. since fig (uses python + pygame) doesnt have turtle commands, here is a similar spiral with cos and sin and line instead:

    # public domain
    npi = -3.14159    times 5
    pi = 0            minus npi
    r = 5
    xb = ""
    yb = ""
    xr = .01
    for p npi pi 0.0314159
        now = r    plus 3.14159     swap now r
        now = xr   plus .01570795   swap now xr   plus p
        x = now    times 12         cos           times r   int    plus 400
        y = now    times 12         sin           times r   int    plus 300
        c = now    times 1000       mod 7                   int    plus 8
        ifequal xb ""
            now line xb  yb x  y c
            xbp = xb    plus 1
            xp  = x     plus 1
            now line xbp yb xp y c
        xb = x
        yb = y
    now lineinput


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s