Playing with Python library Turtle

Turtle is a fun tool to play simple graphics on python language. Imagine a robotic turtle starting at 0:0 and moves accordingly to your code.
After doing little tweaks, I came up with the simple code that shows some art).

Here is the code:
import turtle
from turtle import *
import random
from random import *
#get cursor to default - center position
colors = ['red', 'purple', 'blue', 'green', 'yellow', 'orange']
#loop for 100 iterations
for x in range(100):
#random color
turtle.color(colors[randint(0, 5)])
#randomly go in any direction X, Y - randomly, within 600 pixels
turtle.goto(randint(-300, 300), randint(-300, 300))
#draw a circle with random radius 0-50pxls, 50))
More about the Turtle, can be read over here:

This is the cool tool to introduce programming to children.


I am passionate about creating stuff and want to change the world.

No comments:

Post a Comment