Is an action in a single alternative decision structure is performed only when the condition is true?

The Python language is not sensitive to block structuring of code.

False

The if statement causes one or more statements to execute only when a Boolean expression is true.

Python allows you to compare strings, but it is not case sensitive.

False

Nested decision statements are one way to test more than one condition.

True

Python uses the same symbols for the assignment operator as for the equality operator.

False

The not operator is a unary operator which must be used in a compound expression.

False

Short -circuit evaluation is only performed with the not operator.

False

Expressions that are tested by the if statement are called Boolean expressions.

True

Decision structures are also known as selection structures.

True

An action in a single alternative decision structure is performed only when the condition is true.

True

The decision structure that has two possible paths of execution is known as

dual alternative

Which logical operators perform short-circuit evaluation?

or, and

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?

if y >= 10 and y <= 50:

A Boolean variable can reference one of two values which are

True or False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?

x &lt; y or z &gt; x

True

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?

x &lt; y and z &gt; x

False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8?

not (x &lt; y or z &gt; x) and y &lt; z

False

What does the following expression mean?

x &lt;= y

x is less than or equal to y

Which of the following is the correct if clause to determine whether choice is anything other than 10?

if choice != 10:

When using the __________ logical operator, both subexpressions must be true for the compound expression to be true.

When using the __________ logical operator, both subexpressions must be true for the compound expression to be true.

The __________ statement is used to create a decision structure.

if

In flowcharting, the _______ symbol is used to represent a Boolean expression.

diamond

A(n) _______ decision structure provides only one alternative path of execution.

single alternative

In a decision structure, the action is ______ executed because it is performed only when a specific condition is true.

conditionally

A(n) ______ operator determines whether a specific relationship exists between two values.

relational

A(n) _________ statement will execute one block of statements if its condition is true or another block if its condition is false.

if-else

Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested decision structure simpler to write.

if-elif-else

The logical ________ operator reverses the truth of a Boolean expression.

not

Boolean variables are commonly used as ______ to indicate whether a specific condition exists.

flags

A(n) _____ expression is made up of two or more Boolean expressions.

compound

Chapter 4 Programming
4.1
A decision structure allows a program to perform actions only under certain conditions – also known as selection structures. In its simplest form a specific action is performed only if a certain condition exists. If the condition does not exist the action is not performed.
Single alternative decision structure – because it provides only one alternative path of execution. If the condition In the diamond symbol is true we take the alternative path. Otherwise we exit the structure.
Writing a Decision Structure in Pseudocode
If condition Then Statement Statement Statement
End If

Boolean Expressions and Relational Operators
Booleans Expressions – expressions that can be evaluated as either true or false. Typically is formed with a relational operator. A relational operator determines where a specific relationship exists between two values.

Checkpoint
4.1 What is a control structure?
A logical design that controls the order in which a set of statements executes.
4.2 What is a decision structure?
A logical design that can execute only under certain circumstances
4.3 What is a single alternative decision structure?
Design structure that provides only one path of execution. If the condition in the diamond symbol is true, we take the alternative path. Otherwise, we exit the structure.
4.4 What is a Boolean Expression?
Expressions that can be evaluated as either true or false.
4.5 What types of relationships between values can you test with relational operators?
> Greater than, < Less Than, >= Greater than or equal to, <= Less than or equal to, == Equal to, != Not equal to
4.6 Write a pseudocode If-Then statement that assigns 0 to x if y is equal to 20.
If y=20 Set 0 =x
End If
4.7 Write a pseducode If-Then statement that assigns 0.2 to commission if sales is greater than or equal to 10,000.
If sales >=10,000 Set commission =0.2
End I
A dual alternative decision structure will execute one group of statements if its Boolean expression is true, or another group if its Boolean expression is false.

Dual alternative decision structure – has two possible paths of execution – one path is taken if a condition is true and other path is taken if the condition is false.
In Pseudocode we write a dual alternative structure as an If-Then-Else statement.
If condition Then Statement Statement Etc.
Else
Statement Statement Etc.
End If
In general format the condition is any Boolean expression. If the expression is true, the statements that appear next are executed up to the line that reads Else. If the expression is false the statements that appear between Else and End

Checkpoint
4.8 How does a dual alternative structure work?
One path is taken if the condition is true if it is false the other path Is taken
4.9 What statement do you use in pseudocode to write a dual alternative decision structure?
If-Then-Else statement
4.10 When you write an If-Then-Else statement, under what circumstances do the statements that appear between Else and End If execute?
When the statement is false

4.3 Comparing Strings
Most programming languages allow you to compare strings. This allows you to create decision structures that test the value of a string.

Checkpoint
4.11
If the following pseudocode were an actual program what would it display? z Is not less than a
4.12
S1
S2

4.4 Nested Decision Structures
To test more than one condition, a decision structure can be nested inside another decision structure.

The If-Then-Else If Statement
IF condition_1 Then Statement Statement Etc.
Else If condition_2 Then Statement Statement Etc.

Insert as many Else If clauses as necessary
Else
Statement Statement Etc.
End If

Checkpoint
4.13 How does a dual alternative structure work?
To qualify two conditions must exist. If the first condition is true we need to test the

Does the If statement causes one or more statements to execute only when a Boolean expression is true?

In Python, the if statement is used to create a decision structure, which allows a program to have more than one path of execution. The if statement causes one or more statements to execute only when a Boolean expression is true.

Which structure determines the order in which a set of statements executes?

A control structure is a logical design that controls the order in which a set of statements execute.

Which of the following is the correct If clause to use to determine whether choice is other than 10?

Review of Python Chapter 2.

Which logical operators perform short

Which logical operators perform short-circuit evaluation? Short-circuit evaluation is performed with the not operator.