# for variable in range(stop)
# -- start at: 0
# -- stops at: stop-1
for x in range(10):
print(x)
# for variable in range(start, stop)
# -- start at: start
# -- stops at: stop-1
print("--")
for y in range(1,6): # 1, 2, 3, 4, 5
print(y)
# for variable in range(start, stop, increment)
# -- start at: start
# -- stops at: stop-1
# -- adjust value by increment each time
print("---")
for value in range(5, 102, 10):
print(value)
# for loops can also go inside functions.
# note that code inside a function is indented,
# and the code inside a for loop is indented.
def printALot():
for number in range(0, 10):
print("hello", number)
print("--")
printALot()
# for loops can be used for MUCH MORE than just printing
# numbers. Here is the drawSquare function simplified using
# a for loop
def drawSquareLoop(side):
t.pendown()
t.setheading(0)
for count in range(0, 4):
t.forward(side)
t.right(90)
# This calls the function to draw a 100 pixel square
drawSquareLoop(100)