wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Binary decision making

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of an if-then statement in programming?

a)

To perform a calculation

b)

To make a decision based on a condition

c)

To repeat a block of code

d)

To store data

2.

In an if-then statement, what happens if the condition is false?

a)

The code inside the if block is executed.

b)

The code inside the else block is executed.

c)

The program terminates.

d)

Nothing happens.

3.

What is the purpose of an else statement in an if-then-else statement?

a)

To provide an alternative action if the condition is true.

b)

To provide an alternative action if the condition is false.

c)

To repeat a block of code.

d)

To store data.

4.

if x > 10 :

print ("x is greater than 10")

What will happen if x is equal to 15?

a)

x is greater than 10" will be printed.

b)

Nothing will be printed.

c)

An error will occur.

d)

The program will terminate.

5.

if x < 10:

print ("x is greater than 10")

else: print ("x is less than or equal to 10")

What will happen if x is equal to 5?

a)

"x is greater than 10" will be printed.

b)

"x is less than or equal to 10" will be printed.

c)

Nothing will be printed.

d)

An error will occur.

6.

Which of the following is a valid (right) condition for an if statement?

a)

5

b)

hello

c)

x > y

d)

if x > 10

7.

What is the difference between an if-then statement and an if-then-else statement?

a)

An if-then statement has no condition.

b)

An if-then-else statement has no condition.

c)

An if-then statement executes code if the condition is true

an if-then-else statement executes code whether the condition is true or false

d)

There is no difference between them.

8.

If the light is red, then you must stop.

What action is required when the light is red?

a)

You will Move

b)

You must Stop

c)

You will turn Left

d)

You will Turn Right

9.

In If - then condition the statement after then is always

a)

True

b)

False

10.

In If - then - else condition the statement after else is always

a)

True

b)

False