Cole LaPlante Project 1
The purpose of this project was to create shapes with turtle in order to familiarize ourselves with python and the terminal interface. We became more familiar with parameters, functions, and more aspects of python through drawing simple shapes together. The goal eventually was to create complex images with few lines of code.
Task 1: shapeOne.py
I found the interior angle of a star online, which is 36 degrees, so I had to make the turtle go forward, then turn left(144) at each corner of the star and repeat it.
Task 2: shapeTwo.py
I found the interior angle of an octagon, which is 135 degrees, so I repeated the forward and left(45) commands eight times for each side of the octagon.
Task 3: shapes.py
I quickly realized that a star doesn't easily fit in an octagon. So, with trial and error, I was able to make the turtle draw the octagon so it appears that the star is close to perfectly centered. This is the code I used for shapeThree.
I used trial and error to find what positive x and what negative y value placed the octagon where it looked best.
Task 4: shapeFive.py
I created stars of increasing sizes. What made the composition particularly interesting was the fact that they all had one corner that was exactly at (0,0).
Extension 1: extension1.py
I randomized the location of the shapeThree function so that it created a random array of 30 octagons with stars in the center.
I liked how the star looked in the octagon, so I tried to place them all over an area. I could have done more of them, but it took a decent amount of time for the turtle to draw just thirty of them.
this was the function I used to do that:
for i in range(30):
ranx = x + random.randint(-150,150)
rany = y + random.randint(-150,150)
What is a variable? A variable is a word or letter in a function that allows for code to be affected in different places at the same time.
What is a function and how are they useful? Functions are lines of code that are interpreted by python and carry out a specified action in an efficient way.
What is a parameter and how do they affect the generality of a function? Parameters are where values can be inputted into a function to make the function act in a specific way. For example, the parameters for the function to draw a block are the length and width.
How can you use functions to create complexity with less code? Functions can create complexity when you ask functions to carry out functions inside of functions, importing a function from another line of code.
Pick a wall drawing by Sol LeWitt that you think is interesting. Why? Do you think you could write code for it in python? I definitely think I could if I am able to figure out how to fill in shapes. The image is essentially just stars, but between each set of lines is a different color. It wouldn't be that hard to create a repeating order of three colors.
I learned the basics of using functions with python, and also the basics of parameters. I learned the process of making a project on TextWrangler, which is much more trial and error than anything else. I also learned the basic errors you can make while writing python code.