wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Forloops Drill

Total questions: 7

Worksheet time: 5mins

Name
Class
Date
1.

What is the right way to write the function:

makePancakes (Clue: this pancake will be made by putting 3 balls)

a)

function makePancakes(){

putBall();

putBall();

putBall();

}

b)

function makePancakes()

putBall();

putBall();

putBall();

c)

function makePancakes: {

putBall();

putBall();

putBall();

}

d)

function makePancakes(){

putBall();

}

2.

What is the symbol used for the INCREMENT operator in JS?

a)

+

b)

++

c)

=

d)

==

3.
A condition is __________.
a)
any expression that evaluates to True or False
b)
a built-in function that assigns a Boolean value to a variable
c)
a formula that is executed for a result
d)
an operand that indicates both conditions are True or False
4.

for(let i = 1; i < 6; i++){

putBall();


How many times will a ball be placed?

a)

5

b)

6

c)

7

d)

8

5.

Why do we use a for loop in programming

a)

Easier to read

b)

It's more efficient

c)

To repeat an action a number of times

d)

It helps with sequencing

6.

Which code is correct? Karel starts at 0,0.

a)

for(let i = 0; i < 4; i++){

move();

}

putBall();

b)

for(let i = 0; i < 2; i++){

move();

}

putBall();

c)

for(let i = 0; i < 3; i++){

move();

}

putBall();

7.

which code is correct? Karel starts at 0,0

a)

for(let i = 0; i < 2; i++){

move();

turnLeft();

move();

}

putBall();

b)

for(let i = 0; i < 3; i++){

move();

turnLeft();

move();

}

putBall();

c)

for(let i = 0; i < 1; i++){

move();

turnLeft();

move();

}

putBall();