#Functions
#Defineing functions
#keyword: def--creat or define our function
def name():
Dothis
Then do this
finally do this
#Calling functions:name()
def my_function():
print("Hello")
print("Bye")
my_function()
#draw square
def turn_right():
turn_left()
turn_left()
turn_left()
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_right()
move()
#6.1 The Hurdles Loop
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
move()
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
for step in range(6):
jump()
#Indentation
#While Loops
'''
For
for item in list_of_items:
#Do something to each item
for number in range(a,b):
print(number)
While
while something_is_true
#Do something repeatedly
Infinite Loop:
while 5>3:
'''
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
move()
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
while not at_goal:
jump()
#Hurdles Challenge using While Loops
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_left()
move()
turn_right()
move()
turn_right()
move()
turn_left()
while at_goal() !=0:
if wall_in_front():
jump()
else:
move()
#Jumping over Hurdles with Variable Heights
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_left()
while wall_on_right():
move()
turn_right()
move()
turn_right()
while wall_on_right():
move()
turn_left()
while not at_goal():
if wall_in_front():
jump()
else:
move()
#Escaping the Maze
def turn_right():
turn_left()
turn_left()
turn_left()
while front_is_clear():
move()
while not at_goal():
if right_is_clear():
turn_right()
move()
elif fornt_is_clear():
move()
else:
turn_left()