Day 18 - Field of Flowers using Nested Loops, Random, and Turtle modules

Let's play and explore with nested loops, random and the turtle module. We'll end up with a randomly-generated field of flowers.

Finished Code

from turtle import *
import random

intPetals = 8
flAngle = 360 / intPetals

speed(0)

screen = Screen()
screen.bgcolor("cornflowerblue")

for y in range(10,400,5):

    flScale = y / 400
    intX = random.randint(-500,500)
    teleport(intX, y*-1)

    setheading(90)
    pensize(7 * flScale)
    color("green")
    forward(120 * flScale)

    pensize(1)
    color("yellow")
    for p in range(0,intPetals):
        begin_fill()
        for x in range(0,2):
            circle(5 * flScale, 140)
            circle(100 * flScale,40)
        end_fill()
        right(flAngle)

    forward(5 * flScale)
    right(90)
    color("black")
    begin_fill()
    circle(-10 * flScale)
    end_fill()

hideturtle()
done()