NEW
Font size
WorksheetsKarel Conditions
Total questions: 13
Worksheet time: 7mins
How many times does Karel move with this loop?
9
0
10
1
What does this error mean?
missing ( ) { }
missing ;
missing (
there is no function in the program
Why do we use if/else statements in JavaScript?
To repeat something for a fixed number of times
To either do something if a condition is true or do something else
To break out of some block of code
To repeat something while a condition is true
Which conditional statement should be used for this situation:
If the front is clear, Karel should move. Otherwise, Karel should turn around.
if
if
if
if
else
none of these
Which conditional statement should be used for this situation:
If there is a ball, Karel should take it. Then Karel should move forward.
if
if
if
if
else
none of these
Which conditional statement should be used for this situation:
If there is a ball present, Karel should take it. If the front is clear, Karel should move forward.
if
if
if
if
else
none of these
Which conditional statement should be used for this situation:
If there is a ball present, Karel should take it. If there is no ball present, Karel should turn around.
if
if
if
if
else
none of these
What condition should be used in this while loop for Karel to pick up all the tennis balls at the current location?
while (________) {
takeBall();
}
noBallsPresent()
ballsPresent()
frontIsClear()
takeBall()
Which of the following is not a valid condition to go in an 'if' statement for Karel?
ballsPresent()
frontIsClear()
leftIsBlocked()
turnLeft()
Say you want to write a program for Karel to put down 300 tennis balls. Which control structure would you use?
If statement
While loop
For loop
Nested while loop
What is the purpose of using a 'for' loop in code?
To perform an action if a condition is true
To perform an action while a condition is true
To repeat an action a fixed number of times
To make programs run faster
What does this code do?
Puts down a row of balls
Puts down a column of balls
Puts down balls in a line up to the wall
Removes all of the balls along a path to the wall
What is the best code to replace condition in this code to make Karel move to the wall in front of her?
facingNorth()
frontIsClear()
noWallsPresent()
facingWall()
true
