Lab 2

Lab Description: I was assigned with creating a turtle blast with python. This orders the turtle in python to randomly move forward up to 150 pixels while moving backwards a random distance. It also moves right randomly up to 45 degrees which will later display something like the picture below.

Code:

import turtle
import random
eddie=turtle.Turtle()
wn=turtle.Screen()
wn.bgcolor("red")
eddie.pencolor("white")


for num in range(100):
    distance=random.randint(0,150)
    angle=random.randint(0,45)
    eddie.right(angle)
    eddie.forward(distance)
    eddie.backward(distance)

Screenshots:

Turtle Blast

Leave a Reply

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