Handouts: Karel Reference
File: step_up.py

Karel starts in the world on the left. How would you program Karel to pick up the beeper and transport it to the top of the ledge? Karel should drop the beeper at the corner of 2nd Street and 3rd Avenue and then continue one more corner to the east, ending up on 4th Avenue. At the end of your program, Karel's world should look like the picture on the right.

If Karel only knows the commands:

move()
pick_beeper()
put_beeper()
turn_left()


How can you make Karel turn to the right?

## Solution

from karel.stanfordkarel import *

"""
File: step_up.py
------------------------
Your first example Karel program. Have Karel pick up the beeper in front
of it and place it on top of the ledge.
(This is a comment. Your computer will ignore it.)
"""

def main():
"""
When you start your program, this code will be executed.
"""
move()
pick_beeper()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
"""
Defines a new command called turn_right that makes
Karel turn right by turning left 3 times.
"""

# this is a single-line comment. Computers ignore it.
turn_left()
turn_left()
turn_left()

# There is no need to edit code beyond this point

if __name__ == "__main__":
run_karel_program()