NEW
Font size
WorksheetsBinary decision making
Total questions: 10
Worksheet time: 5mins
What is the purpose of an if-then statement in programming?
To perform a calculation
To make a decision based on a condition
To repeat a block of code
To store data
In an if-then statement, what happens if the condition is false?
The code inside the if block is executed.
The code inside the else block is executed.
The program terminates.
Nothing happens.
What is the purpose of an else statement in an if-then-else statement?
To provide an alternative action if the condition is true.
To provide an alternative action if the condition is false.
To repeat a block of code.
To store data.
if x > 10 :
print ("x is greater than 10")
What will happen if x is equal to 15?
x is greater than 10" will be printed.
Nothing will be printed.
An error will occur.
The program will terminate.
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?
"x is greater than 10" will be printed.
"x is less than or equal to 10" will be printed.
Nothing will be printed.
An error will occur.
Which of the following is a valid (right) condition for an if statement?
5
hello
x > y
if x > 10
What is the difference between an if-then statement and an if-then-else statement?
An if-then statement has no condition.
An if-then-else statement has no condition.
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
There is no difference between them.
If the light is red, then you must stop.
What action is required when the light is red?
You will Move
You must Stop
You will turn Left
You will Turn Right
In If - then condition the statement after then is always
True
False
In If - then - else condition the statement after else is always
True
False
