











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Review: Primitive Karel Commands
1 2 3 (^1 2 3 4 )
1 2 3 (^1 2 3 4 )
The MoveBeeperToLedge Program */
Defining New Functions
function name () { statements that implement the desired operation }
The turnRight Function
function turnRight() { turnLeft(); turnLeft(); turnLeft(); }
Exercise: Defining functions
function turnAround() { turnLeft(); turnLeft(); } function backup() { turnAround(); move(); turnAround(); }
Control Statements
Using the repeat Statement
function makeBeeperSquare() { repeat (4) { putBeeper(); move(); turnLeft(); } }
Conditions in Karel
The if and if - else Statements
if ( condition ) { statements to be executed if the condition is true } if ( condition ) { statements to be executed if the condition is true } else { statements to be executed if the condition is false }
function test() { putBeeperLine(); turnLeft(); putBeeperLine(); } Exercise: Creating a Beeper Line
The End