Turtle Lab

Description:

I learned how to import turttle and random module. I the had to follow these instructions

• Change the color of the window to “red” using he .bgcolor property of the screen variable you create.
• Your turtle variable has to have a pen color “white”, you have to use the .pencolor property of your turtle variable.
• You have to make your turtle to change its heading to the right with an random angle between 0 and 45 degrees.
• Move your turtle forward a random distance between 0 and 150 pixels.
• Then move the turtle backward the same distance than above
• Repeat the last three steps 100 times.

 

Code:

import turtle
import random

wn=turtle.Screen()
wn.bgcolor(“red”)

victor=turtle.Turtle()
victor.color(“white”)

for i in range(100):
rand=random.randint(0,45)
randd=random.randint(0,150)
victor.right(rand)
victor.forward(randd)
victor.backward(randd)

 

Screenshots:

Code picture

 

Leave a Reply

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