# Pages CS 151 Computational Thinking Fall 2012 Assignment2 Jess

Jessica Mullaney

Directory for Python files: in jlmullan/Project 2

The purpose of this task was to use python and turtle to create various shapes, which I then used to make some outdoor scenes.  The color and width functions helped to transform the shapes into a more interesting picture. In scene 1, I developed a code for a house with a scale factor that allowed me to make multiple houses of different size just by changing one number.

Code for house:

turtle.forward(base)

turtle.left(90)

turtle.forward(1.2*base)

turtle.left(45)

turtle.forward((2*((base/2)*2))*.5)

turtle.left(90)

turtle.forward((2*((base/2)*2))*.5)

turtle.left(135)

turtle.forward(base)

turtle.left(180)

turtle.forward(base)

turtle.left(90)

turtle.forward(1.2*base)

turtle.left(90)

turtle.forward(.4*base)

turtle.left(90)

turtle.forward(.5*base)

turtle.left(270)

turtle.forward(.2*base)

turtle.left(270)

turtle.forward(.5*base)

I also used the function "pencolor" to make the outline of the house brown and a width of 4.  To make a seesaw in the scene, I made two isosceles triangles of the same size and placed a parallelogram on top of it. The lamp was the most complicated figure in this scene.  I started it by first drawing a thin, tall rectangle for the base.  Then I created a loop function for the lamp to make the light appear as a starburst.  The outline of the light I made orange, and I used the fill function to fill it yellow.

Code for light portion of lamp:

for i in range (60):

turtle.pencolor('orange')

turtle.begin_fill()

turtle.width(4)

turtle.right(135)

turtle.forward(light)

turtle.left(160)

turtle.forward(light)

turtle.end_fill()

For the second scene I began by making a blue line of width 10 for the “road” and then a trapezoid for the body of a car.  For the wheels of the car I used a decagon function.  The speed limit sign was made next.  I made the code for the body of the sign before I created the code for the numbers on it, since this order made it easier to scale the numbers and come up with their x,y positions.  Lastly, I came up with one function for a star with a scale factor and used a fill color of yellow.  The random function was imported to draw 20 differently sized stars at different locations in the sky.

Code for star:

turtle.fillcolor('yellow')

turtle.begin_fill()

for i in range(5):

turtle.forward(side)

turtle.left(144)

turtle.end_fill()

Code for random stars:

for i in range(20):

landscape2.star(random.randint(300,300),random.randint(150,420), random.randint(10,100))

The extensions I chose to undergo included using the random function to generate 20 random stars and using the color, width, and fill functions in my two scenes.

This project helped me become much more familiar with making pictures using turtle.  I learned how to move shapes around on screen to create images, how to use random to make a scene more interesting, and how to use the fill and color functions. I also learned how to use scale factors to make many different sizes of an image.  One very useful thing I learned was turtle.seth(0), which I used to reset the cursor in between images.  Overall I am now much more proficient at using turtle than I was before this project.

Picture1(practice scene)

Picture2 (scene1)

Picture3 (scene2)

Labels