WorksheetsSECURITY: Unit 4 Review
Total questions: 20
Worksheet time: 11mins
How can we improve the following program?
Break down the 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 and remove a bracket
In the following code, what happens to Karel if a ball is present?
Karel will put down a ball
Karel will move
Karel will stop
Karel will pick up the ball
What is the purpose of using a FOR loop in code?
To do something if a condition is true
To repeat something a fixed number of times
To do something if a condition is false
To make the program run faster
What makes the following command an invalid Karel command?
turnleft();
the semicolon shouldn't be there
the 'l' should be a capital 'L'
it should start with a capital 'T'
the command is correct
What is wrong with this code?
The go function is called twice
The go function has a syntax error
The go function has been defined twice
The go function does not work
How many total times will Karel move in this program?
5
6
7
8
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
A bakery has 10 cookies in its inventory. How can you store this information in a JavaScript variable?
var = cookies + 10;
var cookies = 10;
var cookies == 10;
cookies = 10 Var()
Why do programmers 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
If statement
Define a function
You want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?
If statements
While loop
New function
For loop
Which of the following items in the array is [2]?
Milk
Eggs
Cookies
Cake
What is an array (or list)?
An unordered collection of unique items
An ordered collection of items
A collection of (key, value) pairs
A collection of items stored at (row, column) locations
In this example, what Country will print on the screen?
Greece
Spain
Australia
Russia
Why do we use if/else statements in JavaScript?
To do something if a condition is true and do something else if the condition is false
To repeat something for a fixed number of times
To do some if the the condition is false only
To repeat something while a condition is true
Which of these is a valid Karel command?
move();
move()
move;
Move();
Which type of programming language translates the entire code before running any of the instructions/steps?
interpreted
compiled
scripting
markup
What will be printed as a result of the following code segment?
Dylan
Jacob
Jacob
Dylan
Julia
Jacob
Jacob
Julia
Which data type is a number without a decimal component?
char
string
integer
float
Text and numbers within " " in programming is called a:
number
word
character
string
