Chapter 3 Flashcards
What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?
x < y or z > x (T/F)
false because If (x=5) < (y=3), this is False.
AND = the condition, both must be true.
(z=8) > (x=5), this is True
The whole statement is False because it uses the AND condition not the OR condition.
What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8?
! (x < y or z > x) and y < z (T/F)
False
Why: … First:
NOT = operator #1, this means the value of this expression must be reversed. so…
Second:
[ (x=5) < (y=3), expression 1 is False
Third:
OR = the operator #2, one of these must be true. (z=8) > (x=5) ], expression 2 is True - so far the sub-expression 1, in brackets, is True.
Write an if clause to determine whether x is anything other than 10?
if choice !=10:
Write an if-else statement that assigns 0 to the variable y if the variable x is less than 10. Otherwise it should assign 99 to the variable y.
Write nested decision structures that perform the following: if x is greater than 10 and y is less than 100, display the greater of x and y.
Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?
A __________ structure can execute a set of statements only under certain
circumstances
decision
A __________ structure provides one alternative path of execution
single alternative decision
In pseudocode, the If-Then statement is an example of a _________.
decision structure
A(n) _________ expression has a value of either true or false
boolean
The symbols >,
relational
A(n) _________ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.
dual alternative decision
You use a(n) _________ statement in pseudocode to write a single alternative decision structure.
if-then
You use a(n) _________ statement in pseudocode to write a dual alternative decision structure.
If-Then-Else
A _________ structure allows you to test the value of a variable or an expression and then use that value to determine which statement or set of statements to execute.
multiple alternative decisions