LAB 2

Turtle Blast

This lab consisted of us learning the how to run the program python. The basis of the program was pretty easy to understand. However when i came across turtle i ran into some difficulties. I could not figure out how to run the program properly, however with some help from my Professor i was able to continue my coding to for the turtle blast lab. The code that i wrote consisted of creating a line that went from a random angle of 0-45. After which it went a random distance between 0-150. After which it went back to its origin point. This procedure was repeated a 100 times. The end result can be seen in screen shot below after the coding.

Coding used:

import turtle
import random
wn = turtle.Screen()
wn.bgcolor(“red”)        # set the window background color
angle = random.randint(0, 45)
tess = turtle.Turtle()
tess.color(“white”)              # make tess blue
tess.pensize(3)                 # set the width of her pen
distance = random.randint(0, 150)
for i in [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,34,35,36,37,38,39,40,41,42,43,44,45,4,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,6,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99]:
tess.right(angle)
tess.forward(distance)
tess.backward(distance)
angle = random.randint(0, 45)
distance = random.randint(0, 150)
tess.right(angle)
tess.forward(distance)
tess.backward(distance)

aa

 

Leave a Reply

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