generated from mwc/lab_iteration
I changed the square function to using a for-loop instead of having to write the turtle function multiple times.
Checkpoint 1: - It wasn't that difficult for me because I have a little prior coding experience. I tried multiple different things and realized I could make the numbers in the list the same as the parameter so each side of the square would be that number.
This commit is contained in:
17
square.py
17
square.py
@@ -1,17 +1,10 @@
|
||||
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)
|
||||
|
||||
sizes = [20, 40, 60, 80, 100]
|
||||
for size in sizes:
|
||||
square(size)
|
||||
sizes = [side_length, side_length, side_length, side_length]
|
||||
for side in sizes:
|
||||
forward(side)
|
||||
right(90)
|
||||
square(100)
|
||||
input()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user