wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Karel Programming

Total questions: 39

Worksheet time: 23mins

Name
Class
Date
1.

A set of steps or rules to follow to solve a particular problem.

a)

algorithm

b)

Decomposition

c)

Function

d)

control structures

2.

The process of breaking down your code into smaller parts (more functions)

a)

Decomposition

b)

Indentation

c)

lowerCamelCase

d)

Start Function

3.

Teaching the computer a new command. Used to explain what a program should do when receiving that command.

a)

Defining a Function

b)

Calling a Function

c)

Start Function

d)

Readability

4.

Used to teach Karel a new word or command. Using these allows programs to be broken down into smaller pieces and makes it easier to understand.

a)

Functions

b)

Control Structures

c)

algorithms

d)

Indentation

5.

Choose TWO: Ways (using syntax) that you can write comments?

a)

multi-line

"""/*

*

*/"""

b)

single line

//

c)

multi-line

**

d)

single line

#

6.

Which of the following commands is a valid Karel command?

a)

move

b)

move( )

c)

move( );

d)

move;

7.

Which of the following is the correct way to define a turnRight function in Karel?

a)

function turnRight() {

turnLeft();

turnLeft();

turnLeft();

}

b)

function turnRight() {

turnRight();

turnRight();

turnRight();

}

c)

function turnRight {

turnLeft();

turnLeft();

turnLeft();

}

d)

turnRight function() {

turnLeft();

turnLeft();

turnLeft();

}

8.

Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?

a)

If statement

b)

While loop

c)

For loop

d)

Nested while loop

9.

What is top down design?

a)

Top down design is a way to use loops and if statements to decompose the problem

b)

Top down design is a way of designing your programs starting with the individual commands first

c)

Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.

d)

Top down design is a way that you can create designs on a computer to put on a web page

10.

How can we improve the following program?

function start() {

move();

move();

move();

move();

move();

move();

move();

move();

move();

}

a)

Break down this program into more functions

b)

Use a for loop to repeat the move command

c)

Use a while loop to repeat the move command

d)

Fix the indentation of this program

11.

What is the purpose of using a for loop in code?

a)

To do something if a condition is true

b)

To do something while a condition is true

c)

To repeat something a fixed number of times

d)

To make programs run faster

12.

Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs?

move();

putball();

move();

move();

move();

move();

move();

a)

Karel will end on Street 1, Avenue 2

b)

Karel will end on Street 1, Avenue 7

c)

this code won’t run because of a syntax error

d)

Karel will crash into a wall

13.

What’s wrong with this code?

function start() {

move();

go();

go();

}


function go() {

move();

move();

}


function go() {

move();

move();

}

a)

The go function is called twice

b)

The go function has a syntax error

c)

The go function has been defined twice

d)

go is not a command that Karel understands

14.

In this code, how many times is the dance function called and how many times is it defined?

function start() {

move();

dance();

move();

move();

turnLeft();

dance();

dance();

}


function dance() {

turnLeft();

move();

turnLeft();

turnLeft();

move();

turnLeft();

}

a)

Called 1 time, defined 1 time

b)

Called 1 time, defined 3 times

c)

Called 3 times, defined 1 time

d)

Called 3 times, defined 3 times

15.

A message in your code that explains what is going on -- not apart of the executing of the program.

a)

Decomposition

b)

Comment

c)

Condition

d)

Control Structure

16.

What is conditional statement in programming?

a)

A conditional statement in programming is a statement that is used to perform mathematical calculations.

b)

A conditional statement in programming is a statement that is used to declare variables.

c)

A conditional statement in programming is a statement that performs different actions based on whether a certain condition is true or false.

d)

A conditional statement in programming is a statement that performs the same actions regardless of whether a certain condition is true or false.

17.

What is the importance of indentation in programming?

a)

Indentation has no impact on code readability.

b)

Indentation improves code readability and maintainability.

c)

Indentation makes the code more difficult to understand.

d)

Indentation is only necessary for aesthetic purposes.

18.

What is the purpose of an if statement in programming?

a)

An if statement in programming is used to perform mathematical calculations.

b)

An if statement in programming is used to declare variables.

c)

An if statement in programming is used to perform different actions based on whether a certain condition is true or false.

d)

An if statement in programming is used to perform the same actions regardless of whether a certain condition is true or false.

19.

Each Karel command ends with a () and a ;.

a)

True

b)

False

20.

What is decomposition?

a)

Searches the computer's memory for data

b)

Repeats a program

c)

Getting small part of a problem and adding them together

d)

Breaking down a complex problem

21.
Abstraction is.....
a)
The process of drawing abstract pictures.
b)
The process of assigning values to variables.
c)
The process of breaking down problems.
d)
The process of removing unnecessary details from a problem.
22.
Decomposition is a term used to define...
a)
The process of assigning value to a variable.
b)
The process of taking out unnecessary details from problems.
c)
The process of breaking down problems into smaller problems.
d)
The process of coding a problem.
23.
For Loop
a)
Repeating actions that have a predetermined beginning, end, and increment (step interval)
b)
a named group of programming instructions; reusable abstractions that reduce the complexity of writing and maintaining programs
c)
A base-16 number system that uses sixteen distinct symbols 0-9 and A-F to represent numbers from 0 to 15.
d)
A precise sequence of instructions for processes that can be executed by a computer
e)
Application Program Interface: a collection of commands made available to a programmer
24.
Function
a)
a named group of programming instructions; reusable abstractions that reduce the complexity of writing and maintaining programs
b)
Repeating actions that have a predetermined beginning, end, and increment (step interval)
c)
To repeat in order to achieve, or get closer to, a desired goal.
d)
parts of a problem's solution (the overall goal); helps you focus on figuring out which block(s) you need rather than trying to solve the whole problem at once.
e)
a description of the behavior of a command, function, library, API, etc.
25.
Loop
a)
The action of doing something over and over again.
b)
the optimal time a program takes to run on a computer, the optimal time or number of people required to create, the optimal number of resources required to run, etc
c)
A programming language with many commands and features designed to make common tasks easier to program; encapsulated as combinations of low level commands.
d)
a named group of programming instructions; reusable abstractions that reduce the complexity of writing and maintaining programs
e)
a collection of commands / functions, typically with a shared purpose
26.
Top Down Design
a)
aka "stepwise design", a problem solving approach in which you break down a system to gain insight into the sub-systems that make it up.
b)
Application Program Interface: a collection of commands made available to a programmer
c)
The action of doing something over and over again.
d)
a simplified representation of something more complex; allows you to hide details to help you manage complexity, focus on relevant concepts, and reason about problems at a higher level.
e)
A generic term for a type of programming statement (usually an if-statement) that uses a Boolean condition to determine, or select, whether or not to run a certain block of statements.
27.

A_______is a sequence of instructions that is continually repeated until a certain condition is reached.

a)

Pixels

b)

Sequence

c)

Loop

d)

Algorithm

28.

How does an else statement differ from an if statement?

a)

It always executes, regardless of conditions

b)

It executes when the 'if condition' is true

c)

It executes when the 'if condition' is false

d)

It can only be used with numbers, not booleans

29.

This code:

putBall();

move();

putBall();

put 2 balls in the same place and then move one place?

a)

True

b)

False

30.

The code in the picture will move Karel in a square.

a)

True

b)

False

31.

Which code will put Karel in the position shown in second world?

a)

putBall(); putBall(); move(); move();

b)

move(); putBall(); move(); putBall();

c)

putBall(); move(); putBall(); move();

d)

move(); putBall(); putBall(); move();

32.

Precondition: Karel is in location (1,1) facing east.

Which code below will put Karel in the position shown in picture?

a)

move(); Move(); turnLeft(); move();

b)

move; move(); turnLeft; move();

c)

move(); move(); TurnLeft(); Move();

d)

move(); move(); turnLeft(); move();

33.

Which code will put Karel in the position shown in second world?

a)

putBall(); putBall(); move(); move();

b)

move(); putBall(); move(); putBall();

c)

putBall(); move(); putBall(); move();

d)

move(); putBall(); putBall(); move();

34.

Is this function written correctly?

a)

True

b)

False

35.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();

36.

How many times should Karel turn left in order to turn right?

a)

1

b)

2

c)

3

d)

4

37.

What can be used to teach Karel to turn right?

a)

Functions

b)

Variables

c)

Dog Treats

d)

Karel can already turn right

38.

Karel needs to move forward, then turn left, then move forward, then put down a ball.

a)

move();

turnLeft();

move();

putBall();

b)

move();

turnLeft();

move();

takeBall();

c)

move();

turnLeft();

move();

move();

d)

move();

turnLeft()

move();

putBall()

39.

Karel needs to take the ball that is already present on her initial space then move forward four spaces and place the ball. Then turn Left

a)

takeBall();

move 2 times ();

move 2 times ();

putBall();

turnLeft

b)

takeBall();

move();

move();

move();

move();

putBall();

turnLeft();

c)

takeBall();

move();

move();

putBall();

TurnLeft{};

d)

takeBall();

move(4);

putBall();

turnLeft():