Loops
Basic Karel
Commands
Functions/Commenting
Conditionals
100

What is a loop?

A way to repeat code.

100
How do you command Karel to move?
What is move();
100

move(); is an example of a _________________

What is Command

100
How many times should the start function be defined in a program?
What is 1.
100

Which of the following is not a condition? a. frontIsClear b. turnLeft(); c. isFacingNorth

What is B?

200

Why use a for loop instead of a while loop?

Repeat something a fixed number of times.

200
What is a "street" in Karel World?
What is a row.
200

How many left turns make a right turn?

3

200

What is a code comment?

A way to give notes to someone who is reading your code and explain what is happening

200

What is the point of using an if statement?

To only run condition if a condition is true.

300

Why use a while loop instead of a for loop?

Repeat something as long as a condition is true.

300
What is an "avenue" in Karel world?
What is a column.
300
Write the commands that follow the turnRight function
What is turnLeft(); turnLeft(); turnLeft();
300

How do you start a single line comment?

// double backslash

300

Why do we indent lines of code?

Helps us read loops, conditions, etc.

400

Debug:
for (var i = 0 i < 5 i++) {
 move();
}

Missing semicolons. for (var i = 0; i < 5; i++)...

400

Which one of the following is not a command that super Karel knows? a.) putBall b.) turnAround c.) turnRight d.) Karel knows all of the above

D.

400
If Karel is facing North and the code: turnLeft(); turnLeft(); runs, which direction is Karel facing now?
What is South.
400

How do you start and end a multi-line comment?

/* Comment */

400

Debug this code:
if (frontIsClear) {
    move();
}

Missing parentheses. if (frontIsClear())...

500

Debug:
while (frontIsClear())
    move();
}

Missing opening curly brace. while (frontIsClear()){...

500

What is the command for Karel to pick up a tennis ball?

takeBall();

500
How would you command Karel to move forward two spaces, drop two balls, face north, and finally pick up 2 balls?
What is move(); move(); putBall(); putBall(); turnLeft(); takeBall(); takeBall();
500

What is wrong with this function?
function SOMETHINGWRONG(){...}

What is function buildTower(){ putBall(); putBall(); putBall(); }

500

What does the 'Else' part of an 'If/Else' statement do?

Only runs if a condition is not true.

M
e
n
u