wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming with Karel the Dog I

Total questions: 27

Worksheet time: 16mins

Name
Class
Date
1.

Karel lives in a grid world. Each point on the grid is marked by a dot, and is a location that Karel can be in. The world has streets and avenues.


The __________ run horizontally

a)

avenue

b)

street

c)

soi

d)

lane

2.

Karel's world has streets and avenues. The _________ run vertically.

a)

avenue

b)

street

c)

soi

d)

lane

3.

Which one is not a command in Karel?

a)

move();

b)

putBall();

c)

takeBall();

d)

turnRight();

4.

Select all that are important things to note when you write a command.

a)

You need to write the command exactly as it appears

b)

You need to match the exact capitalization

c)

Make sure to end every command with a ();

d)

Each command goes on its own line.

5.

Every command should end with a (); This is how Karel can understand the command.


These rules are called the ________.

a)

coding ends

b)

formtax

c)

codetax

d)

syntax

6.

How many commands does Karel know?

a)

10

b)

6

c)

5

d)

4

7.

Which coding is correct?

a)

move();

move();

putBal();

move();

move();

b)

move();

move();

placeBall();

move();

move();

c)

move();

move();

takeBall();

move();

move();

d)

move();

move();

putBall();

move();

move();

8.

We can teach Karel to turn right by defining a function called turnRight() that shows Karel how to turn to the right.

Which one is the correct way to define this function?

a)

function turnRight; {

turnLeft();

turnLeft();

turnLeft();

}

b)

function turnRight() ;{

turnLeft();

turnLeft();

turnLeft();

}

c)

function turnRight() {

turnLeft();

turnLeft();

turnLeft();

}

d)

function turnRight(); {

turnLeft();

turnLeft();

turnLeft();

}

9.

we have a set of commands inside of curly braces. This set of commands is called the (a)   body. It is very important to remember that everything Karel is supposed to do when told the command is INSIDE of the curly braces.

10.

What exactly are functions in Karel the Dog?

a)

One way of thinking about functions is to think of them being single commands that Karel knows by a single name

b)

One way of thinking about functions is to think of them being little blocks of commands that Karel knows by a single name

c)

One way of thinking about functions is to think of them being one commands that Karel knows by a specific name

11.

The very first thing we have to decide when creating a function is what to name it. Select all the things we need to remember

a)

The name of a function should always be an action describing the function, just like move() or putBall() are actions.

b)

The name of the function should specifically describe what the function does.

c)

Because it is a name it should start with a capital letter

d)

It can be a silly made up name

12.

Function names must also follow a particular format. Functions whose names are made up of more than one word are always written in a style called Camel Case.

What does that mean?

a)

All words must be capitalized

b)

The first word of a function is lowercase, but all of the other words begin with upper case letters.

13.

Functions should always start with a letter and not contain any other characters besides letters and numbers. What does this mean?

a)

This means that a function name MUST NOT contain spaces

b)

This means that a function name MAY contain spaces

14.

Functions may contain letters and numbers but

a)

may only start with numbers

b)

may only start with letters

15.

After the function has a legal, descriptive name, the next step in creating a function is to _______ and ________ the function.

(a)  

16.

Which of the following are good function names?

a)

goToEnd()

b)

function one()

c)

superimportantfunction()

d)

climbUpTower()

17.

What are the most important rules for function names?

a)

It is a name you can remember

b)

It starts with a letter and has a nice programming sound

c)

It describes what it does, is in Camel Case, and doesn't have any illegal characters.

d)

It starts with a lowercase letter, has a space and the second word is capitalized

18.

True or False:

Commands may be inserted among your functions

a)

True

b)

False

19.

The start() function is a very special function. All of the commands you wish to execute must go (a)   of the start function, between the curly braces. The commands will be executed in the order that they appear.

20.

Why do we use functions in programming?

a)

Break down our program into smaller parts

b)

Avoid repeating code

c)

Make our program more readable

d)

All of the above

21.

How many times should the start function be defined in a program?

a)

1

b)

2

c)

0

d)

As many times you like

22.

If Karel is facing South and the code:

turnLeft();

turnLeft();

runs; which direction is Karel facing now?

a)

West

b)

East

c)

NorthEast

d)

North

23.

Which of the following is incorrect?

a)

putBall()

b)

move();

c)

Takeball();

d)

turnLeft();

24.

True or False Every command must end with {}

a)

True

b)

False

25.

Which of these is a valid Karel command?

a)

move;

move;

b)

move();

c)

MOVE

d)

move()

26.

What command will place a ball down in a spot?

a)

placeBall();

b)

Putball();

c)

putball():

d)

putBall();

27.

If Karel is facing North and the code turnLeft();

turnLeft();

turnLeft();

runs; which direction is Karel facing now?

a)

North

b)

West

c)

East

d)

South