generated from mwc/lab_iteration
I added a for loop to replace the repetition of
the commands to draw each side. No, I just found the code that was repeated and put it in the loop. I understand how to define what is in the loop and how to iterate through the steps. At this point I don't have any questions, but I'm sure as soon as we get more complex I'll have some. Yes, because I like documentation and I have a terrible memory.
This commit is contained in:
parent
afa69468ac
commit
faadb0fd43
12
square.py
12
square.py
|
@ -1,14 +1,10 @@
|
||||||
from turtle import *
|
from turtle import *
|
||||||
|
|
||||||
def square(side_length):
|
def square(side_length):
|
||||||
forward(side_length)
|
for i 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:
|
||||||
|
|
Loading…
Reference in New Issue