generated from mwc/lab_iteration
simplify squre
1 A little bit difficult to think what should put into [] i initially defined a new variable. but after read the prompt closely, I found it unnecessary prompt is helpful.
This commit is contained in:
parent
ad345de973
commit
51f631303f
19
square.py
19
square.py
|
@ -1,16 +1,15 @@
|
||||||
from turtle import *
|
from turtle import *
|
||||||
|
|
||||||
def square(side_length):
|
def square(side_length):
|
||||||
forward(side_length)
|
moves = [1,1,1,1]
|
||||||
right(90)
|
for move in moves:
|
||||||
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:
|
||||||
square(size)
|
square(40)
|
||||||
|
penup()
|
||||||
|
forward(40)
|
||||||
|
pendown()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue