Skip to end of metadata
Go to start of metadata

This project was a practice of writing basic code in python to formulate simple shapes and ways to manipulate them. We used text wrangler to write the code and python in terminal to execute the commands.

For our first task we were asked to create a simple shape. I created an "L" shape by commanding the turtle to draw forward, turn left 90 degrees, and draw forward again.

For our second task we were asked to create another simple shape. Using commands forward and right 90 degrees, I created a square shape.

The third task practiced our ability to create a function. We turned our first two shapes into functions by commanding def (function name)(): and then the commands tabbed below. This meant we had two functions, named shapeA and shapeB after our first simple shape and second simple shape respectively. The third task then asked us to combine these functions in a third shape, which would be a function that combined shapeA and shapeB with a small command in between.

I coded: def shapeC (): 

This function created a third shape that included the two simple shapes connected by a bent line.

The final task was to create a function that included parameters for a shape to make the shape's appearance more flexible, and then create a function that utilized this flexibility by printing the shape in different sizes. I named the first function, which was a square with flexible parameters, shapeD. To create this, instead of specifying a set distance after the command forward, I typed the word distance, and between each flexible distance I coded a right turn of 90 degrees.
instead of forward(100), I typed forward(distance); and for the function setup instead of coding def shapeD():, I coded def shapeD(distance):
this allowed me to create a shape which could change size depending on the variable distance of each side

I then coded function shapeE to create four shapeD's of different size by tabbing: shapeD(specified side length) four times underneath def shapeE():. I made the four shapeD's of side length 50, 100, 200, and 300.

In this project I learned how to open and save files through terminal, type code in text wrangler and utilize python as a way to draw basic shapes. I learned how to keep my code neat and organized, and how to revise it for errors. i also learned to develop lab write-ups on the CS151 wiki page.

I was aided during this project by:
Mrs. Taylor

  • No labels