generated from mwc/lab_iteration
Rewrote square function using iteration.
- No, the wording of the lab was a little confusing because it says to use list iteration but you don't actually need a list for it. Also, the function still "calls" forward and right four times; we only wrote it once.
This commit is contained in:
11
square.py
11
square.py
@@ -1,14 +1,9 @@
|
||||
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)
|
||||
for _ in range(4):
|
||||
forward(side_length)
|
||||
right(90)
|
||||
|
||||
sizes = [20, 40, 60, 80, 100]
|
||||
for size in sizes:
|
||||
|
||||
Reference in New Issue
Block a user