NEW
Font size
WorksheetsUnit 3 Karel Programming Review 2
Total questions: 15
Worksheet time: 12mins
Which of the following is used to create a loop that executes as long as a condition is true?
for
do-while
while
loop
Why would we use a while loop instead of a for loop?
we don't know how many times we want to run the loop
we know how many times we want to run the loop
It's a structure that is more efficient to code and execute
it's best practicies
Control structure that lets us do either one section of code or another depending on a test.
If Statement
If/Else Statement
For loop
While Loop
What type of error occurs when the program runs but produces incorrect results?
Syntax error
Runtime error
Logic error
What is the purpose of using an 'if' statement?
To define a new function.
To import external libraries.
To make decisions based on conditions.
To repeat a block of code.
What is a run-time error?
A mistake that occurs during the execution of a program
A mistake in the syntax of the code
A mistake in the logic of the code
A mistake that occurs during code compilation
Which of the following is not a valid condition to go in an if statement for Karel?
ballsPresent()
frontIsClear()
leftIsBlocked()
turnLeft()
How many total times will Karel move in this program?
2
3
4
5
What condition should be used in this while loop to get Karel to move until there is a wall in the way?
noBallsPresent();
ballsPresent();
frontIsClear();
turnLeft();
Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?
If statement
While loop
For loop
Nested while loop
You need to write a program that has Karel move if the front is clear, but if it isn’t clear, Karel will do nothing.
Which control structure do you need to use?
For Loop
While Loop
If Statement
If/Else Statement
None of these
What do we use control structures for in JavaScript?
Control the flow of the program; how the commands execute.
Start our JavaScript program
Store information for later
Teach Karel new commands
Which of the following are control structures:
- "if" function
- "if/else" function
- "while" function
- "for" function
1 and 2
1 and 2
3 and 4
1, 2, 3, and 4
Why does a programmer indent their code?
Helps show the structure of the code.
Easier for other people to understand.
A key part of good programming style!
All of the above
