Lab 2: Turtle Blast

Lab Description:

In this lab I used the program python to create a program to show an output screen like the one shown on lab 2: turtle blast.  First I had to import the turtle and import the screen.  To change the background color I had to use the .bgcolor property and to change the the color of my turtle variable by using the .pencolor property.  Since I had to repeat some of the steps 100 times I used the range command to repeat those steps 100 times.

Source Code:

import turtle
import random
wn = turtle.Screen()
alex = turtle.Turtle()
wn.bgcolor(“red”)
alex.pencolor(“white”)

for i in range(100):
alex.right(random.randint(0, 45))
distance = random.randint(0, 150)
alex.forward(distance)
alex.backward(distance)

Screen Shots: In the screen shots you will see the screen shot of the source code and the results of the code.

turtle blast result

Untitled

Leave a Reply

Your email address will not be published. Required fields are marked *