Loops 1
Loops 2
Functions
Conditional statements
Coding style
Vocab
Wild card
100

What is the difference between an IF statement and a WHILE loop?

IF statement only runs once, WHILE loop can run multiple times depending on a condition.

100

When do you use a FOR loop?

When you need to repeat something a fixed number of times.

100

What function do you never call?

start() function
100

What should you indent in an IF statement?

Everything between the curly brackets { }

100

How do you write a single line comment?

// You use two forward slashes


move(); // You can also comment on the same line as code

100

What can be used to teach Karel to turn right?

A. Functions      B. Variables      C. Loops      D. Dog treats

A. Functions

200

Using the following loop, how many times will Karel move?

for (var i = 0; i < 8; i++) {

        move();

}

8 times

200

Karel needs to follow a line of balls but you don't know how many. Which type of loop should you use?

While loop

200

What are the two things you must do with a function when coding?

1. Define the function

2. Call the function

200

What are the possible values of a condition like frontIsBlocked() or noBallsPresent()?

True or false

200

How do you write a multi-line comment?

/* Use a forward slash and star to begin

And a star and forward slash to end */

200

What is syntax?

The rules for how you must type code for a certain programming language.

200

What are the rules for naming a function?

- Name should start with a letter

- No spaces

- Name should describe what the function does

300

What is the proper syntax in Karel for a FOR loop?

for (var i = 0; i < #; i++) {

\* Type loop body here *\

}

300

Karel needs to clean up a bunch of balls in different places. The world is always going to be 5 spaces wide. What loop(s) should Karel use? What should the loop(s) do?

While loop to pick up each pile of balls.

For loop to move across the world and call a cleanup function.

300

What is the proper syntax in Karel for defining a function called eatHamSandwich?

function eatHamSandwich() {

/* Type function body here */

}

300

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!

300

What is top-down design?

Start with a big problem and break it into smaller parts.

300

What is pseudocode?

Short phrases that explain what you want your code to do. You can write this before you write the real code.

300

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

400

What does i++ mean?

Increase i by 1

400

Give an example of an infinite (never ending) FOR loop.

for(var i=0; i>-1; i++){

putBall();

}

400

What is the proper syntax in Karel for calling a function named devourBagel?

devourBagel();

400

What is the proper syntax in Karel for an if...then statement?

if ( condition() ) {

/* run this code if true */

}

400

What are pre-conditions and post-conditions when it comes to functions?

Mr. Porter will say the answer out loud.

400

What is camel case?

A good way to write function names:

makePancakes   finishBellwork   stayOnTask   askQuestions   workTogether   beKindToEachOther

400

Karel is facing North. After the following code, which direction is Karel facing?

turnLeft();

turnLeft();

move();

South

500

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++)

500

Give an example of an infinite (never ending) WHILE loop.

while(noBallsPresent()){

turnLeft();

}

500

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

500

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 */

}

500

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.

500

What is nesting?

Nesting is writing a loop inside a loop or a conditional inside a conditional or calling a function inside another function.

500

Define a function with correct syntax to teach Karel to turn around and move forward 1 space. Name the function using camel case.

function turnAroundAndMove() {

     turnLeft();

     turnLeft();

     move();

}

M
e
n
u