Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Coding Conditionals

Total questions: 14

Worksheet time: 14mins

Name
Class
Date
1.

What operation is correct for the given condition?

4 __ 5

a)

<

b)

>

c)

<=

d)

>=

e)

==

2.

What operation is correct for the given condition?

7 __ 5

a)

<

b)

>

c)

<=

d)

>=

e)

==

3.

What operation is correct for the given condition?

5 __ 5

Select all that apply.

a)

<

b)

>

c)

<=

d)

>=

e)

==

4.

What operation is correct for the given condition?

c __ 5

Select all that apply.

a)

<

b)

>

c)

<=

d)

>=

e)

!=

5.

Which statement is correct?

a)

If the water level is reached, then turn off the motor. If the water level is not reached, then measure the level and repeat the sequence.

b)

If the water level is reached, then measure the level. If the water level is not reached, then turn off the motor.

c)

If the water level is reached, then turn off the motor. If the water level is not reached, then turn off the motor.

d)

If the water level is reached, then measure the level. If the water level is not reached, then measure the level and repeat the sequence.

e)

If the water level is reached, then turn off the motor. If the water level is not reached, then measure the level.

6.

What is the purpose of an if-else statement?

a)

The purpose of an if-else statement is to execute the code block multiple times.

b)

The purpose of an if-else statement is to execute different code blocks based on a condition.

c)

The purpose of an if-else statement is to execute the code block only if the condition is false.

d)

The purpose of an if-else statement is to execute the same code block regardless of the condition.

7.

What are the possible values of a boolean expression?

a)

yes, no

b)

1, 0

c)

on, off

d)

true, false

8.

How do you write a boolean expression that checks if a variable is equal to a specific value?

a)

variable = specific_value

b)

variable == specific_value

c)

variable != specific_value

d)

variable > specific_value

9.

How do you write a boolean expression that checks if a variable is not equal to a specific value?

a)

variable == specific_value

b)

variable <> specific_value

c)

variable =! specific_value

d)

variable != specific_value

10.

What is the difference between the '==' operator and the '!=' operator?

a)

The '==' operator checks if two values are greater than or equal, while the '!=' operator checks if two values are less than or equal.

b)

The '==' operator checks if two values are equal, while the '!=' operator checks if two values are not equal.

c)

The '==' operator checks if two values are not equal, while the '!=' operator checks if two values are equal.

d)

The '==' operator checks if two values are identical, while the '!=' operator checks if two values are not identical.

11.

What happens if there is no else statement in an if-else statement?

a)

The code inside the if block will be executed if the condition is true, and if the condition is false, the program will continue to the next line of code after the if-else statement.

b)

The code inside the if block will be executed if the condition is true, and if the condition is false, the program will enter an infinite loop.

c)

The code inside the if block will be executed if the condition is true, and if the condition is false, the program will throw an error.

d)

The code inside the if block will be executed if the condition is true, and if the condition is false, the program will terminate.

12.

What is the purpose of using if-else statements in programming?

a)

To repeat a block of code multiple times.

b)

To define a function.

c)

To perform mathematical calculations.

d)

To make decisions based on conditions.

13.

What will the monitor display?

a)

The is the if body.

This is outside the if block.

b)

The is the if body.

c)

This is outside the if block.

d)

error

14.

The clock reads 11 PM.

What will be the result?

a)

I am going to sleep.

b)

I am going to do my math homework.

c)

I am going to get started.

d)

error