Deck 3: Control Structures
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/129
Play
Full screen (f)
Deck 3: Control Structures
1
A control statement is a statement that determines the control flow of a set of instructions.
True
2
"Control structure" is another name for a control statement.
False
3
Sequential, selection and iterative control are all based on a given condition.
False
4
Most programs are straight-line programs.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
5
Control flow refers to
A) the order that instructions are executed in a program
B) the speed at which a set of instructions are executed in a program
C) the changing values of variables in a program
A) the order that instructions are executed in a program
B) the speed at which a set of instructions are executed in a program
C) the changing values of variables in a program
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following provide explicit control flow in a program?
A) sequential, selection and iterative control statements
B) selection and iterative control
C) sequential and selection control
A) sequential, selection and iterative control statements
B) selection and iterative control
C) sequential and selection control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following is not a fundamental form of control that programming languages provide?
A) sequential control
B) iterative control
C) secondary control
A) sequential control
B) iterative control
C) secondary control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
8
Most computer programs use
A) sequential and selection control
B) sequential, selection and iterative control
C) sequential and iterative control
A) sequential and selection control
B) sequential, selection and iterative control
C) sequential and iterative control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
9
Match the descriptions with their terms:
-based on a condition that is checked once
A) sequential control
B) selection control
C) iterative control
-based on a condition that is checked once
A) sequential control
B) selection control
C) iterative control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
10
Match the descriptions with their terms:
-implicit form of control
A) sequential control
B) selection control
C) iterative control
-implicit form of control
A) sequential control
B) selection control
C) iterative control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
11
Match the descriptions with their terms:
-based on a condition that may be checked many times
A) sequential control
B) selection control
C) iterative control
-based on a condition that may be checked many times
A) sequential control
B) selection control
C) iterative control
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
12
The order that instructions are executed in a program is called _____________________.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
13
11. Statements that determine the flow of control of a set of instructions are called _____________________.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
14
The three forms of control provided by programming languages are ________________,__________, and __________________ control.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
15
Program that do not have any form of control flow other than sequential control are called__________________________.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
16
What is the term for the order that instructions are executed in a program?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
17
What is the term for a statement that determines the control flow of a set of instructions?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
18
What are the three forms of control flow provided by programming languages?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the three forms of control flow is implicit in a program?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
20
What is the term for a program that does not have any control flow, other than sequential control?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
21
Which forms of control flow require the use of a condition?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
22
Which form of control flow repeatedly executes a set of instructions?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
23
The Boolean data type contains two Boolean values?
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
24
A Boolean expression is an expression that evaluates to True or False.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
25
All Boolean expressions contain at least one Boolean literal (value).
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
26
Boolean literals True and False are considered Boolean expressions.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
27
All relational operators produce a Boolean result (value).
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
28
The == operator is used for the assignment of Boolean values.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
29
The != operators is used to determine if two values are not equal to each other.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
30
The relational operators can be applied to string values.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
31
The Boolean expression 'Abe' < 'Apple' evaluates to true.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
32
The Boolean expression 'apple' < 'Banana' evaluates to true.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
33
The membership operator in of Python can be used to determine if a given value occurs in a particular tuple, or if a given substring occurs in a given string value.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
34
In order to determine if a certain value is not in a particular list (or string), the membership operator not in can be used.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
35
The operators and, or, not, ==, !=, <, <=, >, >= are called Boolean operators.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
36
1 <= num <= 10 is not a valid Boolean expression in most programming languages, but is allowed in Python.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
37
Operator precedence applies to the arithmetic operators and relational operators, but not to the Boolean operators.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
38
All Boolean operators are applied before any relational operators.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
39
Short-circuit evaluation is when a Boolean expression contains the invalid use of Boolean operators.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
40
not (num == 0) and num != 0 are logically equivalent Boolean expressions, for integer value num.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
41
not (num != 0) is logically equivalent to num < 0 and num > 0, for integer value num.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
42
num1 <= num2 is logically equivalent to not (num1 > num2), where num1 and num2 each contain an integer value.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
43
not (flag1 and flag2) is logically equivalent to (not flag1) and (not flag2), where flag1 and flag2 are Boolean values.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
44
not (flag1 or flag2) is logically equivalent to (not flag1) and (not flag2), where flag1 and flag2 are Boolean values.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following is not a Boolean operator?
A) and
B) or
C) not
D) with
A) and
B) or
C) not
D) with
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
46
Examine the following statements.
X = 10
X == 10
What will the second line evaluate to?
A) False
B) 10
C) True
D) None of the Above
X = 10
X == 10
What will the second line evaluate to?
A) False
B) 10
C) True
D) None of the Above
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
47
Examine the following expression:
10 < 20 and 30 > 50
What does this expression evaluate to?
A) True
B) False
C) True and False
D) That line of code is not valid in Python and will result in an error
10 < 20 and 30 > 50
What does this expression evaluate to?
A) True
B) False
C) True and False
D) That line of code is not valid in Python and will result in an error
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
48
Examine the following expression.
10 in (10, 20, 30)
What will this expression evaluate to?
A) False
B) 10
C) True
D) None of the Above
10 in (10, 20, 30)
What will this expression evaluate to?
A) False
B) 10
C) True
D) None of the Above
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
49
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x != y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-not (x != y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
50
Match the expressions that they are logically equivalent to the Boolean expressions :
-(not x) or (not y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-(not x) or (not y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
51
Match the expressions that they are logically equivalent to the Boolean expressions :
-(not x) and (not y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-(not x) and (not y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
52
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x >= y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-not (x >= y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
53
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x == y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-not (x == y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
54
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x > y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
-not (x > y)
A) x < y
B) x <= y
C) x == y
D) x != y
E) not (x and y)
F) not (x or y)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
55
True and False are the two _________ values in Python.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
56
A _____________ expression is an expression that evaluates to True or False.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
57
The Boolean operators in Python are _____, _____, and _____.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
58
Both the Boolean and _____________ operators evaluate to a Boolean result.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
59
Fill in the table, evaluating the Boolean expressions for x and y with the given values. Some have already been filled in.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
60
Evaluate the following Python expressions.
-14 <= 14
-14 <= 14
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
61
Evaluate the following Python expressions.
-5 > 4 or 12 < 8
-5 > 4 or 12 < 8
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
62
Evaluate the following Python expressions.
-6 != 5
-6 != 5
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
63
Evaluate the following Python expressions.
-10 not in (10, 20, 30)
-10 not in (10, 20, 30)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
64
Evaluate the following Python expressions.
-5 < 10 and 8 > 20 or 4 < 2
-5 < 10 and 8 > 20 or 4 < 2
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
65
Evaluate the following Python expressions.
-not (12 == 12 and 4 < 6)
-not (12 == 12 and 4 < 6)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
66
Evaluate the following Python expressions for the variable assignments given.

-num1 > num2 and flag1

-num1 > num2 and flag1
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
67
Evaluate the following Python expressions for the variable assignments given.

-num1 == 12 or num1 == num2 or flag1

-num1 == 12 or num1 == num2 or flag1
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
68
Evaluate the following Python expressions for the variable assignments given.

-num1 + 10 < num2 and flag2

-num1 + 10 < num2 and flag2
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
69
Evaluate the following Python expressions for the variable assignments given.

-not flag1 or not flag2 and num2 < num1

-not flag1 or not flag2 and num2 < num1
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
70
For each of the following Boolean expressions, indicate the value of x that would make each expression false.
(a) x and True
(b) x or False
(c) not (x or False)
(d) not (x and True)
(a) x and True
(b) x or False
(c) not (x or False)
(d) not (x and True)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
71
Give an appropriate expression for each of the following:
-To determine if the number 25 appears in a list of numbers called nums.
-To determine if the number 25 appears in a list of numbers called nums.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
72
Give an appropriate expression for each of the following:
-To determine if the numbers 10 and 20 do not appear in a list of numbers named nums.
-To determine if the numbers 10 and 20 do not appear in a list of numbers named nums.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
73
Give an appropriate expression for each of the following:
-To determine if the name 'Charles' appears in a list called names.
-To determine if the name 'Charles' appears in a list called names.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
74
Give a logically equivalent expression for each of the following:
-num1 > 0 and num2 > 0
-num1 > 0 and num2 > 0
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
75
Give a logically equivalent expression for each of the following:
-num1 <= 0 or num2 <= 0
-num1 <= 0 or num2 <= 0
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
76
Give a logically equivalent expression for each of the following:
-not (num1 == 0 and num2 == 0)
-not (num1 == 0 and num2 == 0)
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
77
The if statement in Python provides selection control.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
78
If statements always make use of a Boolean expression.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
79
All if statements must include an else header.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck
80
if Statements may contain as many else headers as necessary.
Unlock Deck
Unlock for access to all 129 flashcards in this deck.
Unlock Deck
k this deck