A Refactored Logical Turtle

by Hannah Wang

27 Jan 2016

For this assignment, I chose to refactor my logical turtle, who originally made balloons based on user input and demanded politeness.

Original:

I chose this turtle exercise because I had to do a lot of copying and pasting, which made it a good candidate for functions. I wanted to make the entire act of drawing a balloon one function. This required first defining the two parts of the balloon as two separate functions: the circle and the triangle (tail). Then I called these functions in the drawballoon function.

I also wanted to use the random module to make randomly colored balloons, but I couldn’t figure out how to do that, so instead I used the random module to make randomly-sized balloons, rather than relying on user input.

I loved turning the balloon drawing into a function, because for each balloon I only had to specify the color and the starting point (based on the randomly selected integer).

Politeness is still required.

Refactored:

Hannah Wang is a second semester MSIS student at SILS. Find Hannah Wang on Twitter, Github, and on the web.