Turtle Blast

Lab Description:

Before I started this lab, I was required to read chapter 4 of the Python supplemental textbook and the required textbook Think Python. After reading the chapter, I open the program Python and write a new variable known as turtle. I type out import turtle and import random. Then I make a window for my turtle and make the color red. I name my turtle as my own name and set his color to white. Now that the turtle is created, I make the amount of steps I need to apply for my turtle which is 100. This is where  I write “for n in range(100) since I need to repeat the steps 100 times. Then I use a new function called random.randint and next to it would be (0,45). Then I write alvin.right(angle) so it indicates the range of 0-45. I do the same thing for length and it would be written as length = random.randint (0,150). For the last two lines, I write alvin.forward(length) and the same thing for backward.

Codes: 

import turtle
import random

wn = turtle.Screen()
wn.bgcolor(“red”)
alvin = turtle.Turtle()
alvin.color(“white”)
alvin.pensize(1)

for n in range(100):
angle = random.randint(0,45)
alvin.right(angle)
length = random.randint(0,150)
alvin.forward(length)
alvin.backward(length)

Screenshot of codes and result:

Untitled