Font size
WorksheetsIST CodeHS Unit 7 Programming Concepts Review
Total questions: 22
Worksheet time: 5mins
What is the purpose of IF statement #1?
If there is a ball at the current location, pick it up
If there is no ball at the current location, put one down
If the front is clear, move forward
If there is a ball at the last location, pick it up
What is wrong with this Karel command? Select all that apply: Move;
this command is correct
it should have a lower case m
it should have parentheses
it should not have a semi-colon ;
What is wrong with this code? Select all that apply:
the function name should be Start()
the move() command is undefined
the go() function is undefined
the go() function is called twice in a row
How many tennis balls will Karel put down in this program?
4
5
6
0
What is the best way to define a function that turns Karel around at the same location?
function turnAround() { turnLeft(); turnLeft(); }
function turn() {
turnLeft();
turnRight(); }
function turnAround() {
turnRight();
turnRight();
turnRight(); }
turnAround function() {
move();
turnLeft();
move(); }
What is the correct way to write a single line comment in JavaScript?
//comment
/* this is a multi-
* line comment
* using JS
*/
#comment
this is a comment
Which of these is a valid Karel command?
turnLeft();
turnBack();
goForward();
goLeft();
What control structure should we use if we want Karel to move and turn left 8 times in a row?
For loop
While loop
If statement
Function
How should a For loop that is meant to repeat an action 10 times be written in JavaScript?
for (var i=0; i<10; i++) { }
for (i=0, i<10, i++) { }
for (var i=10; i<0; i++) { }
for (i=10, i<0, i++) { }
If Karel starts at Row 2, Column 1 facing South, where will Karel end up and what direction will she be facing after running this code?
Karel will crash into the wall at Row 1, Column 1, Facing South
Row 1, Column 1, Facing East
Row 2, Column 1, Facing North
Row 1, Column 2, Facing West
Karel begins at Row 4, Column 4 facing East. What is her ending location and direction after running the code?
Row 4, Column 6, Facing North
Row 3, Column 5, Facing South
Row 4, Column 6, Facing East
Row 3, Column 6, Facing West
Karel begins at Row 2, Column 3 facing North. What is her ending location and direction after running the code?
Row 4, Column 4, Facing East
Row 2, Column 4, Facing West
Row 4, Column 2, Facing West
Karel crashes into a wall
Assume Karel is a 5 x 5 world (5 Rows and 5 Columns). What location describes the center of this world?
Row 3, Column 3
Row 2, Column 2
Between Rows 2 and 3, and between Columns 2 and 3
Row 4, Column 4
Assume you want Karel to move around the edge of a world, but you don't know the size of the world. (Example: it might be 5 x 5 or maybe 10 x 10) What control structure would work best to accomplish the continuous movement?
For loop
While loop
If statement
If/Else statement
What is a benefit of using well-named and well-defined functions in a program?
It makes the code more understandable and avoids repeated code
It makes the code more understandable and the program will run faster
It avoids repeated code and therefore makes the program run faster
It avoids syntax errors and makes the code more readable
What is a good Postcondition comment for this function?
Karel is one spot above a tennis ball facing East
Karel is on a spot with a tennis ball facing East
Karel goes around the tennis ball facing East
Karel is on a spot with a tennis ball facing North
If we call the stairStep function and then put a tennis ball down and repeat those actions 5 times, what kind of shape will we make?
A diagonal line of 5 tennis balls going North-East
A straight horizontal line of 5 tennis balls
A straight vertical line of 5 tennis balls
A diagonal line of 5 tennis balls going South-East
If Karel begins at Row 1, Column 2 facing East and the stairStep function is called twice, what will be Karel's final position and direction?
Row 3, Column 4, Facing East
Row 2, Column 3, Facing North
Row 4, Column 3, Facing East
Row 2, Column 4, Facing North
What condition should be checked in a While loop to get Karel to pick up all the tennis balls at the current location?
ballsPresent()
noBallsPresent()
frontIsClear()
leftIsBlocked()
What condition should be checked to see if there is a wall (hurdle) in front of her?
frontIsClear()
frontIsBlocked()
facingEast()
facingNorth()
Which of the following is an example of low-level abstraction? Note: The task being described is getting dressed in the morning.
I put on my clothes
I put on a shirt, pants, and shoes
I put on a dress and shoes and combed my hair
I put my left arm through the left arm-hole, then I put my right arm through the right arm-hole, then I put my head through the top of the shirt...
What is the purpose of putting comments in a program?
Comments are necessary for the program to execute properly
Comments are an important part of for loop syntax
Comments are not necessary in a computer program
Meaningful comments help communicate what the program (or function) does to yourself and to other programmers
