generated from mwc/lab_iteration
I used for loop to loop the square 4 times instead of just writing it 4 times.
It wasnt't that difficult. I took CSE 115 over the summer where we learned python.I just used the note for the class to refreash my knowledge of loop.
This commit is contained in:
17
square.py
17
square.py
@@ -1,17 +1,10 @@
|
|||||||
from turtle import *
|
from turtle import *
|
||||||
|
|
||||||
def square(side_length):
|
def square(side_length):
|
||||||
|
for i in [1,2,3,4]:
|
||||||
forward(side_length)
|
forward(side_length)
|
||||||
right(90)
|
right(90)
|
||||||
forward(side_length)
|
square(200)
|
||||||
right(90)
|
square(150)
|
||||||
forward(side_length)
|
square(100)
|
||||||
right(90)
|
square(50)
|
||||||
forward(side_length)
|
|
||||||
right(90)
|
|
||||||
|
|
||||||
sizes = [20, 40, 60, 80, 100]
|
|
||||||
for size in sizes:
|
|
||||||
square(size)
|
|
||||||
input()
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user