generated from mwc/lab_iteration
changed square.py to use list iteration, ck #1
I thought the directions were very clear for the list iteration although I did need to read through them several times, and tried to understand what they were saying before opening the file. I then ran the original code to see what it did, so I could compare my final product. As I worked on the list iteration, I also kept the original code at top commented out so I could refer to it, and did not delete it until I was sure my iteration method worked. I was not totally sure if I could call the list whatever I wanted to, but it seems like I could as long as one of the names is singular and the other is plural. I feel like I have a good grasp of iteration after this part.
This commit is contained in:
parent
883e64b8de
commit
29b250ff83
15
square.py
15
square.py
|
@ -1,14 +1,13 @@
|
|||
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,2,3,4]
|
||||
|
||||
for side in sides:
|
||||
forward(side_length)
|
||||
right(90)
|
||||
|
||||
sizes = [20, 40, 60, 80, 100]
|
||||
for size in sizes:
|
||||
|
|
Loading…
Reference in New Issue