πΆ What command makes Karel move forward one square?
move();
βοΈ What is the correct syntax for defining a new function named turnRight?
function turnRight() {
turnLeft();
turnLeft();
turnLeft();
}
π Which control structure repeats code a fixed number of times?
a for loop
π Why do we use functions in Karel programs? (3 reasons!)
Functions break down our program into smaller parts, avoid repeating code, and make our program more readable.
π What is the only food that can never go bad?
Honey
π Why is this function call invalid?
Turnleft();
Javascript is case-sensitive; should be turnLeft();
π What is the difference between defining and calling a function?
Defining creates it; calling executes it.
Defining uses the "function" keyword and creates a box; calling is just the name
π What is the syntax for a while loop in Karel?
(put ... in place of executable code)
while (condition) {
...
}
π€ What is "top-down design"?
Breaking a problem into smaller parts and solving each one step by step
πWhat is the only U.S. state that can be typed in using only one row of a standard βQWERTYβ keyboard?
Alaska
π What is wrong with this command:
putball();
JavaScript is case-sensitive; it should be putBall(); in lowerCamelCase
π How many times can you define a function in your program? How many times can you call a function in your program?
You can only define a function ONCE with the same name. You can call a function as many times as you want.
π§ When should you use a for loop instead of a while loop?
Use for when the number of repetitions is known. Use while when you want to repeat until a condition is false.
π§± What is a "precondition" and "postcondition" in Karel programming?
Precondition: what must be true before a function runs; Postcondition: what is true after it runs
π₯ The iconic βHollywoodβ sign originally spelled out what word?
Hollywoodland
π¬ What is the purpose of using comments in your code? What are the types? Give one example of each type.
To explain code;
// single-line
/* multi-line */
π§Ή Why do we use indentation in our code?
To make the code more readable and to show structure; to show code is in a "box" of a control structure or function.
All code in a "box" using curly braces {} should be indented by one.
π§° Whatβs the difference between a condition and a command in Karel? Give one example of each.
Condition: returns true/false like frontIsClear(); Command: performs an action like move();
π§© What is "abstraction" and how do functions help with it?
Hiding details to focus on the bigger picture; functions let you reuse code without repeating it. We don't need to know HOW something works to use it.
βοΈ What is the only letter not found in the periodic table of elements?
J
π§± What is an edge case, and why should we test it when programming Karel?
An edge case is an unusual situation usually at the start or end of a algorithm. We need to write code to handle these cases before or after a loop. This helps ensure our code works in all scenarios
π€ Which syntax error is in this line:
function moveTwice() {
move();
move()
}
?
Missing semicolon after second move(); should be move();
π‘ Improve this code with a control structure:
move();
move();
move();
move();
for (var i = 0; i < 4; i++) {
move();
}
πͺ What are the differences between Karel and SuperKarel? Name two commands SuperKarel can use that aren't available in Karel.
SuperKarel has extra commands built in that do not need to be built; turnRight(); and turnAround();
π Where were Doritos invented?
Casa de Fritos at Disneyland