Random Numbers, Tuples, and Lists

More Random Numbers

Drawing circles with random start angle:

import turtle
import random

turtle.speed(9)

colors = ("Green", "Blue", "Orange", "Pink", "Red", "Purple", "Magenta", "Cyan", "Yellow", "Black")

for i in range(100):
    turtle.pencolor(random.choice(colors))
    turtle.pensize(random.randint(2, 7))

    # This line will rotate turtle a random amount before drawing
    turtle.left(random.randint(0, 360))

    radius = random.randint(20, 200)
    turtle.circle(random.choice([-1, 1]) * radius)

turtle.done()

The following example draws larger circles followed by smaller ones, generated randomly:

import turtle
import random

turtle.speed(11)

colors = ("Green", "Blue", "Orange", "Pink", "Red", "Purple", "Magenta", "Cyan", "Yellow", "Black")

circle_density = 2

def draw_a_random_circle(circle_radius):
    turtle.pencolor(random.choice(colors))

    turtle.pensize(random.randint(2, 7))

    turtle.left(random.randint(0, 360))
    turtle.circle(random.choice([-1, 1]) * circle_radius)


for i in range(10 * circle_density):
    radius = random.randint(150, 200)
    draw_a_random_circle(radius)

for i in range(20 * circle_density):
    radius = random.randint(120, 150)
    draw_a_random_circle(radius)

for i in range(30 * circle_density):
    radius = random.randint(80, 120)
    draw_a_random_circle(radius)

for i in range(20 * circle_density):
    radius = random.randint(40, 80)
    draw_a_random_circle(radius)

for i in range(20 * circle_density):
    radius = random.randint(20, 40)
    draw_a_random_circle(radius)

turtle.done()