# Pages CS 151 Computational Thinking Fall 2012 Doug and Naomi

Doug Piper and Naomi Staley

Python files available at nastaley on the Academics sever in the handin directory

Command lists: (used commas in steps 3-6 to denote a new line; lines were numbered)

#1. Draw a star inside of a box with another box in the middle

#2. Draw a rectangle 3 lines tall from one margin to the other, with eight zigzags inside, equally spaced.

Margin: defined by the red line on this paper

Zigzag: a diagonal line top to bottom

#3. pen down, pen forward 2 units, pen left 1 angular unit, pen forward 1 unit, pen left 1 angular unit, pen forward 1 unit, pen right 1 angular unit, pen forward 1 unit, pen left 1 angular unit, pen forward 1 units, pen left 1 angular unit, pen forward 2 units.

#4. ShapeB pen down, go to point (2,-2), go to point (5,-2), go to point (7,0), pen up, forward 2 units, pen down, turn left 1 angular unit, forward 2 units, pen up, forward 3 units, pen down, forward 2 units, pen up, go to (0,0).

#5. Shapes Label:ShapeC, pen down, execute list shapeA, pen up, go to point (2,2), pen down, execute list shapeB, pen up, forward 2, pen down, execute list shapeA.

#6. ShapeD- X=2, Y=1, label: shapeD, pen forward X, pen left, pen forward X, pen left, pen forward Y, pen left, pen forward Y, pen right, pen forward Y, pen right, pen forward Y, pen left, pen forward Y, pen left, pen forward X, pen right, pen forward Y.

ShapeE- X=4, Y=2 execute list shapeD

Clearly for this lab, specific and defined instructions proved to be the most helpful. For example, in the first task, the artist drew a star within a box within another box. But the director wanted a box in a star inside a box. The artist misinterpreted the “with another box in the middle,” thinking it meant another box in the middle of the big box rather than the star.

In the first two tasks the director and artist both knew which way the turtle would be initially facing and basic language information, but there were things missing. Notably, the order or specificity of the drawings were different. For example the star in the first task was of a different size than imagined, and in the second task, the director did not say how evenly spaced to make the zigzags.

After these first two sets of instructions, the director was forced to be much more specific. Rather than using sentences in English, the director used numbered lines. Since computers cannot handle much ambiguity, these rigid steps forced our python drawings to execute our drawings. For example, steps 3 and 4 had each artist following a step by step motion, with a limited number of defined actions. Both tasks drew different shapes but contained similar information.

Once a single shape was drawn, labels were used to make multiple copies. This made it easier to draw complex shapes, as once it was created initially, the pen could be picked up and moved, and using the label, the shape could be drawn again.

Hypothetically, if a set of commands tried to execute itself, the image would potentially repeat. However, we assume that python may have thought of that and realized if someone ever did this it would probably be by accident, and by default cause nothing to happen.

In the third task, if we had used a command list using variables, we could have made an infinite number of shapes, depending on what we made our variables.

In the last task, if shape D was altered, no change would needed to be made to shape E, as long as the variables remained the same. The change in Shape D would be reflected in shape E, however.

All in all, using python was fairly easy. It was just a matter of following instructions and writing it all in text, and once all the parentheses were sorted out, the shapes looked good.

Labels