wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Turtle Programming - Functions Review

Total questions: 7

Worksheet time: 2hrs 45mins

Name
Class
Date
1.

Consider the following incorrect program, which is intended to move the robot around the perimeter of a grid, as indicated by the drawing below. The starting position and direction of the robot is indicated in the diagram.


Line 1: 4 TIMES

Line 2: {

Line 3: MOVE_FORWARD()

Line 4: ROTATE_RIGHT()

Line 5: MOVE_FORWARD()

Line 6: MOVE_FORWARD()

Line 7: MOVE_FORWARD()

Line 8: MOVE_FORWARD()

Line 9: ROTATE_RIGHT()

Line 10: }


Given the options below, which lines should be removed so the program will work as intended?

a)

Line 3 and Line 4

b)

Lines 5, 6, 7, 8 and 9

c)

Line 8 and Line 9

d)

Line 9

2.

Which of the following is NOT true about functions in programming?

a)

Functions are reusable programming abstractions.

b)

Functions help reduce the complexity of writing and maintaining programs.

c)

Functions cannot make calls to other functions within the same program.

d)

Once defined, a function can be called many times from different parts of a program.

e)

Functions help break a problem into logical chunks.

3.

What is one important naming convention of functions?

a)

A function name should indicate how long the function takes to run.

b)

Two functions with similar behavior should be given identical names to indicate the relationship between them.

c)

A function name should be as descriptive as possible to indicate what the function does.

d)

Function names should be organized alphabetically.

e)

The function name should begin with a number that indicates the order in which it should be executed.

4.

Which one of the following statements about functions is TRUE?

a)

A function can change names over the course of a program.

b)

Code can be added or removed dynamically from a function while the program is running.

c)

Functions can be called using different names depending on where in the program they are called.

d)

Two functions can be given identical names as long as their code is identical.

e)

Two functions in a single program can have different names but contain identical code.

5.
A piece of code you can use over and over again
a)
Function
b)
Abstraction
c)
Non-Function
6.

Which of the following will call the function drawStar?

a)

drawStar

b)

drawStar();

c)

function drawStar (){

for(var i=0; i <5; i++) {moveForward(100); turnLeft(36):}}

d)

function drawStar;

e)

function drawStar();

7.

Why are parameters useful when programming?

a)

Parameters determine the number of times the function will run.

b)

Parameters allow for more flexible, generalized behaviors in functions.

c)

Parameters are useful for teams of programmers because they help define the boundaries of the problem they are trying to solve.

d)

Parameters change the order of operations within a function.