lab 2

lab description

in this lab I have to create a turtle that’s heading right in a random angle between 0 and 45 and moving forward in a random distance between 1 to 150, then moving backward the same distance, and repeating these steps by 100 time.

code:

import turtle
wn=turtle.Screen()
wn.bgcolor(“red”)
tess=turtle.Turtle()
tess.color(“white”)
for i in range(100):
import random
a=random.randrange(0,45)
b=random.randrange(1,150)
tess.right(a)
tess.forward(b)
tess.backward(b)

screen shot:

turtle

Leave a Reply

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