Program Description:

This program was created using python and to apply the concepts that I learn in my class lectures. This programs uses the “turtle” and “random” modules to create a random graphic. This program also uses the “for” loop and the range function where we can repeat the the set of statements how many times we want. The program that I created is below and contains comments to show what each line does. There are also two images where the first one shows what can the program do at the end and the second picture shows the script.

import turtle  #Gets the turtle module into python
import random  #Gets the random module into python
wn = turtle.Screen()   #set a variable to the method to create a window or canvas
wn.bgcolor(“red”)   #Change the background color of the canvas or window
r = turtle.Turtle()   #set a variable to the method to create a way to graph
r.pencolor(“white”)   #Change the color of the lines that are going to be draw
r.speed(20) #Change how fast the drawing goes
r.shape(“turtle”) #change the shape of the pen (in this case to a turtle)
for i in range(100):   #A “for loop” function with a range (repeats) of 100
x = random.randrange(0,45)  # variable set to random range (from 0 to 45 degrees)
y = random.randrange(0,150)   # variable set to random range (from 0 to 150 degrees)
r.right(x)   # rotates pen’s face to the right
r.forward(y)   # moves pen forward
r.backward(y)   # moves pen backwards

wn.exitonclick()   #When the drawing stops, it allows you to click on the canvas to close it