Lab 2

In this lab I used the turtle module to create a moving diagram which would have random arrow directions multiple times.

 

 

Code

import turtle
import random
wn= turtle.Screen()
wn.bgcolor("red")
alex=turtle.Turtle()
alex.pencolor("white")
alex.speed(0)
for x in range(100):
 angle = random.randint(0,45)
 alex.right(angle)
 distance1 = random.randint(0,150)
 alex.forward(distance1)
 alex.back(distance1)

 Lab 2 turtles

Leave a Reply

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