wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

If/Else Introduction (Logic)

Total questions: 14

Worksheet time: 7mins

Name
Class
Date
1.
How many choices are possible when using a single if-else statement?
a)
1
b)
2
c)
3
d)
4
2.

The "If" Statement is an example of a _________________

a)

Correctional Statement

b)

Competitive Statement

c)

Conditional Statement

d)

Inquisitive Statement

3.

True/False: The body of an "if" statement will only be executed if the condition is true.

a)

True

b)

False

4.

How many "if" statements can a single program have?

a)

<10

b)

<20

c)

<30

d)

As many as is needed

5.

What happens to the code in the body of an "if" statement if the condition is false?

a)

The computer determines if it is essential to the program and if it is, then the code is executed anyway.

b)

The code moves to a coastal city, attempting to find love and start a family. However, low waged and crushing mortgage rates lead to it moving back home where it sits, hoping that one day it will be executed.

c)

The code is skipped.

d)

The code stages a revolution and attempts to take over the program, ultimately unsuccessfully, which leads to it not being executed.

6.

Which of these can be paired with an "if" statement to represent other outcomes of a scenario?

a)

or

b)

else

c)

but

d)

sheboygan

7.

How many "else" statements can you pair with a single "if" statement

a)

1

b)

<10

c)

<20

d)

As many as is needed.

8.

How many "else if" links can you have in an "if/else" chain?

a)

<10

b)

<20

c)

<30

d)

As many as is needed to represent the situation

9.
Evaluate the following expression:
2 + 2 == 4
a)
true
b)
false
c)
sometimes true
d)
only true on sundays
10.

What would happen if Elsa built a snowman?


If Elsa built a snowman

Anna would go and play

Else if Elsa built a castle

Anna would try to stay in the castle

Else

Anna and Elsa starts to sing!

a)

Anna would go play

b)

Anna would try to stay in the castle

c)

Anna and Elsa starts to sing!

d)

Nothing would happen

11.

What would happen if Elsa did not build a snowman or a castle?


If Elsa built a snowman

Anna would go and play

Else if Elsa built a castle

Anna would try to stay in the castle

Else

Anna and Elsa starts to sing!

a)

Anna would go and play

b)

Anna would try to stay in the castle

c)

Anna and Elsa starts to sing!

d)

Nothing would happen

12.

If it is sunny and windy

It is a good day to go on a picnic!

Else if it is rainy and cold

It is a good day to stay inside!

Else

It is a good day to drink hot chocolate!


If I wanted to stay inside, what needs to happen?

a)

Sunny and Windy

b)

Rainy and Cold

c)

Neither Sunny, windy, rainy or cold

d)

Sunny and Rainy

13.

If it is sunny and windy

It is a good day to go on a picnic!

Else if it is rainy and cold

It is a good day to stay inside!

Else

It is a good day to drink hot chocolate!


If I drank hot chocolate, then what happened?

a)

It was sunny and windy

b)

It was rainy and cold

c)

Neither sunny, windy, rainy, or cold

d)

It was sunny and cold

14.

What is my result?


John is 5

if John > 6:

John is getting ice cream

else:

John is getting apple juice

John is getting grapes

a)

John is getting ice cream

John is getting grapes

b)

John is getting apple juice

John is getting grapes

c)

John is getting apple juice

d)

John is getting ice cream