I rewrote the repeated lines using a for loop.

Checkpoint 1:
It was not difficult. I used the model from the
assignment description to create the loop and
removed the now redundant lines. I ran it with
python square.py to check that it worked, and
it seemed to.
This commit is contained in:
Cory Dean Chung 2023-07-20 12:42:11 -04:00
parent 7273239465
commit daae31288d
2 changed files with 6 additions and 11 deletions

6
poetry.lock generated
View File

@ -497,13 +497,13 @@ sphinx = ">=7.0.1,<8.0.0"
[[package]] [[package]]
name = "urllib3" name = "urllib3"
version = "2.0.3" version = "2.0.4"
description = "HTTP library with thread-safe connection pooling, file post, and more." description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "urllib3-2.0.3-py3-none-any.whl", hash = "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1"}, {file = "urllib3-2.0.4-py3-none-any.whl", hash = "sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4"},
{file = "urllib3-2.0.3.tar.gz", hash = "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825"}, {file = "urllib3-2.0.4.tar.gz", hash = "sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"},
] ]
[package.extras] [package.extras]

View File

@ -1,14 +1,9 @@
from turtle import * from turtle import *
def square(side_length): def square(side_length):
forward(side_length) for sides in range(4)
right(90) forward(side_length)
forward(side_length) right(90)
right(90)
forward(side_length)
right(90)
forward(side_length)
right(90)
sizes = [20, 40, 60, 80, 100] sizes = [20, 40, 60, 80, 100]
for size in sizes: for size in sizes: