Lab 2- Turtle Blast

Description:

This is my lab that constructs a turtle which moves in different direction 100 times and comes back to the same origin.

Code

import turtle  # allows us to use the turtles library
import random
wn = turtle.Screen()   # creates a graphics window
wn = turtle.bgcolor (‘red’)
alex = turtle.Turtle()  # create a turtle named alex
alex.pencolor (“white”)
alex.speed(0)
alex.shape(“turtle”)
for i in range(100):
angle = random.randint (0,45)
alex.right(angle)
distance1 = random.randint (0,150)
alex.forward(distance1)
alex.back(distance1)

screenshot:

turtle

 

Leave a Reply

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