Font size
WorksheetsConditional Statements
Total questions: 22
Worksheet time: 35mins
What is the greater than symbol?
<
<=
>
>=
Which comparison operator is used to check if two variables have the same value?
==
<
>
<=
Which comparison operator is used to check if a variable is less than a specific number?
Logical Operator And : One side or other must be true
True
False
This is the simplest conditional statement which instructs the computer to perform a certain action if the condition is true.
If Statement
If Else Statement
If ElseIf Statement
This conditional statement will perform a certain action if the condition is met. And when the condition is false, an alternative action will be executed.
If Statement
If Else Statement
If ElseIf Statement
If there are more than two alternative choices, using just If…Then…Else statement will not be enough.
In order to provide more choices, we can use:
If Then Statement
If Then Else Statement
If Then ElseIf Statement
Which comparison operator evaluates to True if both sides have the exact same value and False otherwise
!=
=
==
<=
Which comparison operator evaluates to True if both sides have a different value and False otherwise
!=
=
==
<=
Which comparison operator evaluates to True if the left side is less than the right side and False otherwise
>
<
>=
<=
Which comparison operator evaluates to True if the left side is greater than the right side and False otherwise
>
<
>=
<=
Which comparison operator evaluates to True if the left side is greater than or equal to the right side and False otherwise
>
<
>=
<=
Which comparison operator evaluates to True if the left side is less than or equal to the right side and False otherwise
>
<
>=
<=
height = 1.8
Suppose that "height" is defined as above. Which of the following would evaluate to True? Select all that apply.
height > 0
height < 0
height >= 0
height != 0
lives = 0
Suppose that "lives" is defined as above. Which of the following would evaluate to True? Select all that apply.
lives > 0
lives < 0
lives >= 0
lives <= 0
age = 32
Suppose that "age" is defined as above. Which of the following would evaluate to True? Select all that apply.
age == 32
age != 32
age > 65
age < 65
Which of the following will print "YES" if (and only if) "age" is positive?
What will be printed if the value of "num" is 3?
ABC
XYZ
ABC
XYZ
*** ERROR ***
What will be printed if the value of "num" is 0?
ABC
XYZ
ABC
XYZ
*** ERROR ***
What will be printed if the value of "num" is -3?
ABC
XYZ
*** NOTHING ***
*** ERROR ***
What will be printed if the value of "num" is 0?
ABC
XYZ
ABC
XYZ
*** ERROR ***
What will be printed if the value of "num" is -5?
ABC
XYZ
ABC
XYZ
*** ERROR ***
