wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Code.org Unit 3 Functions

Total questions: 35

Worksheet time: 32mins

Name
Class
Date
1.

When programmers work together, what is an example of an abstraction in programming that can promote collaboration?

a)

Team members can rely on one another to explain their code.

b)

Programmers can write functions without needing ot know what they do or how they should work.

c)

Programmers can use functions created by others, relying on the functionality without knowing details of how the function works

d)

In order for programmers to work together, they must be in the same room.

2.

Why are parameters useful when programming?

a)

Parameters change the order of operations within a function.

b)

Parameters help teams of programmers because they define the problems they are trying to solve.

c)

Parameters allow for more flexible, generalized behaviors in functions.

d)

Parameters determine the number of times a function will run.

3.

Look at the following code. Which line should the following comment go? "Shake back and forth"

a)

Line 5

b)

Line 11

c)

Line 14

d)

Line 17

e)

Line 19

4.

Why are functions useful?

a)

They allow us to organize our code

b)

They make our code easier to read

c)

They allow us to create commands that we can use whenever

d)

All of these

5.

Which function would you expect to call if you were trying to have the user move a sprite?

a)

drawBackground()

b)

moveSprite()

c)

changeScore()

d)

gameOver()

6.

Which sprite property replaced the sprite.x = sprite.x + 1

a)

sprite.velocityX

b)

sprite.velocityY

c)

sprite.y

7.

A note in the source code of a computer program that helps explain the code to people who read it:

a)

Comment

b)

Whitespace

c)

CSS

d)

HTML Tag

8.

When calling sprite.IsTouching(target) and you increase the score, why does the score go up so high?

a)

Because the draw() function is a loop and the two sprites are touching many times.

b)

What? no my score only goes up once. The sprites only touch once.

c)

The IDE knows that I don't want to increase the score just by one and gives me a larger number because it thinks it's better to use larger numbers.

d)

Because the sprite don't actually touch once I set sprite.visible = false.

9.

What is the difference between sprite.visible being false and using sprite.destroy ( )?

a)

nothing, they're both the same

b)

sprite.destroy( ) requires that you re-create the sprite

c)

sprite.visible = false will require that you re-create the sprite

d)

because you can no longer see the sprite, then it no longer exists

10.

Give an example of a nested if-condition

a)

if(keyDown(up) and keyDown(left)) then sprite.y = sprite.y + 5;

b)

if (keyDown(up)) then sprite.y = sprite.y + 5;

c)

if (keyDown(up) or keyDown(left)) then sprite.y = sprite.y + 5;

d)

if (keyDown(up)) then if(sprite.y > 400) then sprite.y = 0;

11.

In the draw loop, if you call the text function before the drawSprites and/or background function, what happens?

a)

You won't be able to see your text because the sprites and background will be drawn on top of the text.

b)

You will be able to see your text because Game Lab knows you want to see the text.

c)

You won't be able to see your sprites or background because order doesn't matter.

d)

You will be able to see your text because the sprites and the background will be drawn after the text.

12.

What code do we add to make the elephant push the hippo off the screen?

a)
b)
c)
d)
13.

Predict what will show up on console.log

a)

true true true

b)

true false false

c)

false false false

d)

true false true

14.

What happens in this code?

a)

nothing is shown, there are no sprites

b)

the background is white and we can't see anything because the textsize is 0;

c)

the background is white, the counter increases in size as the counter increase.

d)

the background is white, and we see a number that goes up but the textsize stays the same.

15.

What happens if you don't call background in your draw loop and your sprite has movement?

a)

nothing, animation is fine.

b)

the sprites are drawn on top of each other to simulate movement, the older drawings don't get erased.

c)

you don't need to call background because you don't have one.

d)

you can just use sprite.move( ) so there's no need for the function background( )

16.

What is a good name for the function?

a)

score

b)

totalPoints

c)

backgroundChanges

d)

angryBackground

17.
 A device or component that allows information to be given to a computer
a)
input
b)
output
c)
store
d)
process
18.
Any device or component that receives information from a computer
a)
input
b)
output
c)
store
d)
process
19.
Step 2 in the problem solving process
a)
define
b)
prepare
c)
try
d)
reflect
20.
Step 1 in the problem solving process
a)
define
b)
prepare
c)
try
d)
reflect
21.
The process of putting data in a safe spot  to use later
a)
input
b)
output
c)
store
d)
process
22.
an instance of a computer program that is being executed (thinking)
a)
input
b)
output
c)
store
d)
process
23.

Understanding the problem when it was assigned.

a)

Try

b)

Reflect

c)

Define

d)

Prepare

24.

Examine results. Ask yourself: "What needs to change?"

a)

Define

b)

Prepare

c)

Try

d)

Reflect

25.

The work done (possibly by a computer) to turn input into output

a)

Input

b)

Storage

c)

Output

d)

Process

26.

Elements that make a computer a computer

a)

Input

b)

Output

c)

Process

d)

Storage

e)

All of the above

27.

A precise sequence of instructions for processes that can be executed by a computer

a)

Input

b)

Algorithim

c)

Output

d)

Define

28.

Actually run the plan. Observe any results.

a)

Define

b)

Prepare

c)

Try

d)

Reflect

29.
If you are identifying the problem you are trying to solve, figuring out what your constraints are and determining what success will look like, what part of the problem solving process are you working on?
a)
Define
b)
Prepare
c)
Try
d)
Reflect
30.
Sprite
a)
A graphic character on the screen with properties that describe its location, movement, and look.
b)
 A placeholder for a piece of information that can change.
c)
Attributes that describe an object's characteristics
d)
An algorithm that has been coded into something that can be run by a machine.
31.
Variable
a)
An extra piece of information that you pass to the function to customize it for a specific need.
b)
The common programming structure that implements "conditional statements".
c)
 Attributes that describe an object's characteristics
d)
 A placeholder for a piece of information that can change.
32.
Abstraction
a)
the rate at which frames in an animation are shown, typically measured in frames per second
b)
A graphic character on the screen with properties that describe its location, movement, and look.
c)
Pulling out specific differences to make one solution work for multiple problems.
d)
in programming, an expression that evaluates to True or False.
33.

Where do functions go in a Javascript program on Code.org

a)

At the top

b)

Below the sprites

c)

in the draw loop

d)

Below the draw loop

34.

What does this code do?

a)

Resets the position of the coin sprite

b)

Adds points to the score

c)

Increases the velocity

d)

Sets a random Y value

35.

If I were to put this code in a function, what would I call it?

a)

score

b)

upDownMotion

c)

move

d)

collectCoin