From 9ee9e17edb525dd64889bc54f9c263daae115f1f Mon Sep 17 00:00:00 2001 From: erbrown Date: Sun, 14 Sep 2025 16:03:30 -0400 Subject: [PATCH] created a list and for loop statement using forward and right once rather than four times. Added penup, pendown, and adjusted sizes list. Checkpoint 1: It was not super difficult trying to rewrite the square() using a for - loop. I have taken a computer science course already so I am a little familiar with the for - loop statements. At first I did use the in range (4) command from my background knowledge of computer science but then after I adjusted my sizes = [20,20,20,20] to create the four boxes, I realized I could create a list that would represent the four sides of a square to use the list iteration and for loop after the list. Figuring out the second part of the problem was helpful for me to figure out the top part instead of using the in range () command. --- square.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/square.py b/square.py index f1fb2a2..b1c5059 100644 --- a/square.py +++ b/square.py @@ -1,17 +1,18 @@ from turtle import * def square(side_length): - forward(side_length) - right(90) - forward(side_length) - right(90) - forward(side_length) - right(90) - forward(side_length) - right(90) + sides = [1,1,1,1] + for side in sides: + forward(side_length) + right (90) + -sizes = [20, 40, 60, 80, 100] +sizes = [20,20,20,20] for size in sizes: square(size) + penup() + forward(40) + pendown() input() +