Learn more

Reference


This appendix defines the structure of the Karel programming language on a single page.

Base Karel commnds:

move()
turnLeft()
putBeeper()
pickBeeper()

Karel program structures:

# Comments can be included in any part
# of a program. They start with a #
# and include the rest of the line.

def run() :
   code to execute

declarations of other methods

Names of the conditions:
frontIsClear()
beepersPresent()
beepersInBag()
leftIsClear()
rightIsClear()
facingNorth()
facingSouth()
facingEast()
facingWest()
frontIsBlocked() noBeepersPresent()
noBeepersInBag()
leftIsBlocked()
rightIsBlocked()
notFacingNorth()
notFacingSouth()
notFacingEast()
notFacingWest()
Conditions:

if condition:
code run if condition passes

if condition:
code block for "yes"
else:
code block for "no"

Loops:

for i in range( count):
code to repeat

while condition:
code to repeat

Method Declaration:

defname():
code in the body of the method.

SuperKarel additional commands:

turnRight()
turnAround()
random(p)
paintCorner(color)