Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CodeHS 2.11 If Statements

Total questions: 11

Worksheet time: 7mins

Name
Class
Date
1.

Which of these inputs will cause something to print to the screen?

a)

3

b)

23

c)

0

d)

-5

e)

-1

2.

What will be printed if this code is executed and the user enters 23?

(a)  

3.

Which conditional statement should be used for this situation:


If there is a ball present, Karel should take it. If there is no ball present, Karel should turn around.

a)

if

b)

if

if

c)

if

else

d)

none of these

4.

Which conditional statement should be used for this situation:


If there is a ball present, Karel should take it. If the front is clear, Karel should move forward.

a)

if

b)

if

if

c)

if

else

d)

none of these

5.

Which conditional statement should be used for this situation:


If there is a ball, Karel should take it. Then Karel should move forward.

a)

if

b)

if

if

c)

if

else

d)

none of these

6.

Which conditional statement should be used for this situation:


If the front is clear, Karel should move. Otherwise, Karel should turn around.

a)

if

b)

if

if

c)

if

else

d)

none of these

7.

Which conditional statement should be used for this situation:


Karel should drop a ball and then move forward until she reaches the end of the row.

a)

if

b)

if

if

c)

if

else

d)

none of these

8.

What delimits a condition?

a)

( )

b)

{ }

c)

[ ]

d)

< >

9.

What delimits a block?

a)

( )

b)

{ }

c)

[ ]

d)

< >

10.

What kind of control structure is an if statement?

a)

sequence

b)

selection

c)

iteration

d)

structure

11.

Which of these were today's learning targets?

a)

I can explain the purpose of if statements

b)

I can create my own if statements to select which code is executed in my programs

c)

I can use the selection control structure

d)

I can remember learning targets without writing them down with 100% accuracy

e)

I can use nesting to create complex if statements