From b7d14a11d0c7a23622a109cc51c6569c34a0c03a Mon Sep 17 00:00:00 2001 From: Pat Wick Date: Sun, 16 Jul 2023 20:51:21 -0400 Subject: [PATCH] did both checkpoints before submitting Sorry for that, I guess I should have realized without new changes, committing wasn't really going to work. Anyway, the turtle by default points toward the right, so I used a side-length-then-turn-clockwise pattern to draw the triangle and rectangle. I did have to fix my rectangle though; I forgot the last turn at the end, so while the test worked well, the drawing looked like abstract art. I watched the turtle draw the shapes on my second run of the same incorrect code and noticed the direction changed which is how I knew what to fix. A function is like a variable in that variables store some value, while functions store instructions; in essence, they're both storage devices used to make code easier/more efficient to read, write, and understand. The small, easy problems are the basic under-defined functions that start off the whole problem-solving process. Taking these small pieces and making them into functions that do one specific job allow code to be tested easily as the larger problem is still being solved and make development of code smoother because fixing one problem (hopefully) doesn't break something else somewhere else in the program. An example that I've used with my students was designing a tic-tac-toe game using the turtle functions. Breaking the (simple but) larger problem into pieces might mean "can I just draw an x" so we wrote a function that just makes x's, then one that just made o's, then we used those functions inside of a function that asked the user for a position on the screen, along with another function that chose which symbol to draw depending on the turn counter, to make the game look as intended. --- shapes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/shapes.py b/shapes.py index d6eadaf..c835492 100644 --- a/shapes.py +++ b/shapes.py @@ -21,3 +21,4 @@ def rectangle(height, width): right(90) forward(height) right(90) +