What function do you never call?
How do you write a single line comment?
// You use two forward slashes
move(); // You can also comment on the same line as code
What is a computer?
A computer performs calculations by executing specific instructions to solve a problem.
What can be used to teach Karel to turn right?
A. Functions B. Variables C. Loops D. Dog treats
A. Functions
What are the 3 most general things all computers do?
Input info, process info, output info (also store information)
Using the following loop, how many times will Karel move?
for (var i = 0; i < 8; i++) {
move();
}
8 times
What are the two things you must do with a function when coding?
1. Define the function
2. Call the function
How many values can a condition return? What are those values?
2 values: true and false
How do you write a multi-line comment?
/* Use a forward slash and star to begin
And a star and forward slash to end */
What is syntax?
The rules for how you must type code for a certain programming language.
What are the rules for naming a function?
- Name should start with a letter
- No spaces
- Name should describe what the function does
How do computers store information?
Binary, 1's and 0's
What is the proper syntax in Karel for a FOR loop?
for (var i = 0; i < #; i++) {
\* Type loop body here *\
}
What is the proper syntax in Karel for defining a function called eatHamSandwich?
function eatHamSandwich() {
/* Type function body here */
}
Write a "real life" example of a conditional statement.
Mr. Porter's example: "If students study hard, then they will do well on the quiz and grow 1" taller."
Insert your example here!
What is top-down design?
Start with a big problem and break it into smaller parts.
What is pseudocode?
Short phrases that explain what you want your code to do. You can write this before you write the real code.
How many times should the start function be defined in a program?
How many times should the start function be called in the program?
Defined: 1 time
Called: 0 times
What is the difference between hardware and software?
Hardware - physical components
Software - programs that tell the hardware what to do
What are three ways to write increase the variable i by 1?
i++ (this is the only way you can type it in Karel)
i + 1
i += 1
What is the proper syntax in Karel for calling a function named devourBagel?
devourBagel();
What is the proper syntax in Karel for an if...then statement?
if ( condition() ) {
/* run this code if true */
}
What are pre-conditions and post-conditions when it comes to functions?
Mr. Porter will say the answer out loud.
What is nesting?
Nesting is writing a loop inside a loop or a conditional inside a conditional or calling a function inside another function.
Karel is facing North. After the following code, which direction is Karel facing?
turnLeft();
turnLeft();
move();
South
What is a digital footprint?
What are the three arguments that go into a FOR loop?
1. Define the counter variable (var i = 0;)
2. Specify the end condition (i < 10;)
3. Specify how the loop iterates (i++)
What are three reasons to use functions?
1. Break down the program into smaller parts
2. Avoid repeated code (save time and lines of code)
3. Make the program more readable
What is the proper syntax in Karel for an if...then...else statement?
if ( condition() ) {
/* run this code if true */
} else {
/* run this code if false */
}
Why should you use comments?
To give an explanation/reminder of what your code does. A good approach is to write what you were thinking when you wrote the code.
What is camel case?
A good way to write function names:
makePancakes finishBellwork stayOnTask askQuestions workTogether beKindToEachOther
Define a function with correct syntax to teach Karel to turn around and move forward 1 space. Name the function using camel case.
turnLeft();
turnLeft();
move();
}
What are 3 ways that computers impact your everyday life?
Example answers:
Enables long-distance communication
Provides access to information
Speeds up everyday tasks