Font size
WorksheetsCodeHS Unit 2 Review Programming with Karel
Total questions: 50
Worksheet time: 37mins
move;
In the following code snippet, how many times is the turnRight function called and how many times is it defined?
Called 1 time, defined 1 time
Called 1 time, defined 3 times
Called 3 times, defined 1 time
Called 3 times, defined 3 times
How many times should the start function be defined in a program?
0 times
1 time
2 times
Howevery many you like
How many times should the start function be called in a program?
0 times
1 time
2 times
However many you like
Why do we use functions in programming?
Break down our code into smaller parts
Avoid repeating code
Make our program more readable
All of the above
What is top down design?
Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.
Top down design is a way that you can create designs on a computer to put on a web page
Top down design is a way of designing your programs starting with the individual commands first
Top down design is a way to use loops and classes to decompose the problem
What is the error with the following function definition?
funtionc coverDot() {
move();
putBall();
turnLeft();
}
The D should not be capitalized
The word “function” is misspelled
The curly brackets are missing
There are too many commands
What belongs inside of the start function?
All new function definitions
Nothing
All lines of code in the program
All the commands you wish to execute
The "function body" is the inside of a function. Which of the following is true about the function body?
All code inside should be indented
All code inside should be capitalized
Commands are not allowed inside
You can only have three commands maximum
What line of code will the computer jump to after reading line 4?
Line 17
Line 5
Line 10
Line 1
Which command is written incorrectly?
putBall();
putball();
turnLeft();
takeBall();
The code in the picture will move Karel in a square.
True
False
Which code will put Karel in the position shown in second world?
putBall(); putBall(); move(); move();
move(); putBall(); move(); putBall();
putBall(); move(); putBall(); move();
move(); putBall(); putBall(); move();
Which code below will put Karel in the position shown in picture?
move(); Move(); turnLeft(); move();
move; move(); turnLeft; move();
move(); move(); TurnLeft(); Move();
move(); move(); turnLeft(); move();
Is this Function written correctly?
True
False
What is the name of this function?
function
spin()
3 turnLeft();
spin();
How many times should Karel turn left in order to turn right?
1
2
3
4
What is a code comment?
A way to teach Karel a new word
A way to give notes to the reader to explain what your code is doing
A message to your teacher in code
A place to write whatever you want in your code
What commands does SuperKarel know that regular Karel does not?
turnLeft() and jump()
turnRight() and jump()
turnAround() and turnRight()
turnAround() and jump()
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
How many balls does Karel put down?
(a)
How many balls does Karel put down?
(a)
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
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
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
What’s wrong with this code?
function start() {
move();
go();
go();
}
function go() {
move();
move();
}
function go() {
move();
move();
}
The go function is called twice
The go function has a syntax error
The go function has been defined twice
go is not a command that Karel understands
How many total times will Karel move in this program?
function start() {
move();
for (var i = 0; i < 5; i++) {
move();
putBall();
}
}
1
5
6
7
What is wrong with this for loop?
for (var i = 0, i < 10, i + 1) {
move();
}
I. The for loop uses commas instead of semicolons
II. It should say i++ instead of i + 1
I
II
I and II
The for loop is correct
What is the proper format for a single line comment in Karel?
/* This is a comment
This is a comment
// This is a comment
** This is a comment
Which of the following is not a valid condition to go in an if statement for Karel?
ballsPresent()
frontIsClear()
leftIsBlocked()
turnLeft()
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
How can we teach Karel new commands?
For loop
While loop
Define a new function
The start function
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
Breaking a problem down into smaller problems is called ...
(a)
whatIsThis
(a)
What does the "var" keyword represent in the following code:
for(var i=0; i<12; i++) {
Variation
Varicose
Variable
Varietal
An error in the sequence of words or rules in a program that prevents the program from running
Interpreting
Syntax
Compiling
Executing
Non-executing program statements that provide documentation are ___________.
Comments
Commands
Classes
An if-else statement runs some code if a condition is true, and another block of code if the condition is false.
False
True
How can we improve the following program?
function start() {
move();
move();
move();
move();
move();
move();
move();
move();
move();
}
Break down this program into more functions
Use a for loop to repeat the move command
Use a while loop to repeat the move command
Fix the indentation of this program
