Deck 3: Control Statements and Program Development  

Full screen (f)
exit full mode
Question
Which of the following statements is false?

A) Each sequence has an iterator.
B) The for statement uses the iterator "behind the scenes" to get each consecutive item until there are no more to process.
C) The iterator is like a bookmark-it always knows where it is in the sequence, so it can return the next item when it's called upon to do so.
D) Lists are unordered and a list's items are mutable.
Use Space or
up arrow
down arrow
to flip the card.
Question
________ is an informal English-like language for "thinking out" algorithms.

A) Code
B) Pseudocode
C) Python
D) Quasicode
Question
What does the following for statement print? for counter in range(10):
Print(counter, end=' ')

A) It doesn't run because it's syntactically incorrect.
B) 0 1 2 3 4 5 6 7 8 9 10
C) 1 2 3 4 5 6 7 8 9
D) 0 1 2 3 4 5 6 7 8 9
Question
What does the following line of code display? print(10, 20, 30, sep=', ')

A) 102030
B) 10,20,30
C) 10 20 30
D) 10, 20, 30
Question
Which of the following statements is false?

A) The while statement allows you to repeat one or more actions while a condition remains True.
B) The following code sets product to the first power of 2 larger than 64: product = 2
While product < 64:
Product = product * 2
C) Something in a while statement's suite must ensure that the condition eventually becomes False. Otherwise, a logic error called an infinite loop occurs.
D) In applications executed from a Terminal, Command Prompt or shell, type Ctrl + c or control + c (depending on your keyboard) to terminate an infinite loop.
Question
Which of the following statements a), b) or c) is false?

A) Augmented assignments xe "abbreviating an assignment expression"abbreviate assignment expressions in which the same variable name appears on the left and right of the assignment's =, as total does in: for number in [1, 2, 3, 4, 5]:
Total = total + number
B) The following code re-implements the for statement in Part (a) using an addition augmented assignment (+=) statement: for number in [1, 2, 3, 4, 5]:
Total += number
C) The statement f = f ** 3 may be replaced by the more concise augmented assignment statement f *= 3.
D) All of the above statements are true.
Question
The most important flowchart symbol is the ________, which indicates that a decision is to be made, such as in an if statement.

A) rectangle
B) flowline
C) xe "decision symbol"diamond
D) small circle
Question
Which of the following statements a), b) or c) is false?

A) You form each Python program by combining as many control statements of each type as you need for the algorithm the program implements.
B) With Single-entry/single-exit (one way in/one way out) control statements, the exit point of one connects to the entry point of the next. This is similar to the way a child stacks building blocks-hence, the term control-statement stacking.
C) You can construct any Python program from only six different forms of control (sequential execution, and the if, if…else, if…elif…else, while and for statements). You combine these in only two ways (control-statement stacking and control-statement nesting). This is the essence of simplicity.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) The xe "decision symbol"decision (diamond) symbol contains a condition that can be either True or False.
B) The diamond flowchart symbol has three xe "flowline"flowlines emerging from it.
C) One flowline emerging from the diamond flowchart symbol indicates the direction to follow when the condition in the symbol is True. This points to the action (or group of actions) that should execute.
D) Another flowline emerging from the diamond flowchart symbol indicates the direction to follow when the condition is False. This skips the action (or group of actions).
Question
Which of the following statements is false?

A) The sequence to the right of the for statement's keyword in must be an iterable.
B) An iterable is an object from which the for statement can take one item at a time until no more items remain.
C) One of Python's most common iterable sequences is the list, which is a comma-separated collection of items enclosed in square brackets ([ and ]).
D) The following code totals five integers in a list: total = 0
For number in [2, -3, 0, 17, 9]:
Total + number
Question
Which of the following statements is false?

A) Sometimes the suites in an if…else statement assign different values to a variable, based on a condition, as in: grade = 87
If grade >= 60:
Result = 'Passed'
Else:
Result = 'Failed'
B) You can replace if…else statements like the one above using a concise conditional expression: result = ('Passed' if grade >= 60 else 'Failed')
C) The parentheses in a conditional expression are required; otherwise, a syntax error occurs.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) Any expression may be evaluated as True or False.
B) A condition which evaluates to a nonzero value is considered to be True, and a condition which evaluates to a value of zero is considered to be False.
C) Strings containing characters are True and xe "empty:string"empty strings ('', "" or """""") are False.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) The following code shows two statements in the else suite of an if…else statement: grade = 49
If grade >= 60:
Print('Passed')
Else:
Print('Failed')
Print('You must take this course again')
B) In the code in Part (a), grade is less than 60, so both statements in the else's suite execute.
C) In the code of Part (a), even if you do not indent the else suite's second print statement, it's still in the else's suite. So, the code runs correctly.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) Built-in function print displays its argument(s), then moves the cursor to the next line. You can change this behavior with the argument end, as in print(character, end=' ')
B) Python calls end a keyword argument, and end is a Python keyword.
C) The end keyword argument is optional. If you do not include it, print uses a newline ('\n') by default.
D) Keyword arguments are sometimes called named arguments.
Question
Various Python statements enable you to specify that the next statement to execute may be other than the next one in sequence. This is called ________ and is achieved with Python xe "control statement"control statements.

A) xe "transfer of control"transfer of control
B) alternate execution
C) spread execution
D) None of the above
Question
Which of the following statements is false?

A) xe "indentation"Indenting a suite is required; otherwise, an xe "IndentationError"IndentationError syntax error occurs.
B) If you have more than one statement in a suite, those statements do not need to have the same indentation.
C) Sometimes error messages may not be clear. The fact that Python calls attention to the line is often enough for you to figure out what's wrong.
D) Programs that are not uniformly xe "indentation"indented are hard to read.
Question
Which of the following statements a), b) or c) is false?

A) With a nonfatal xe "logic error"logic error, an IPython interactive session terminates.
B) For a fatal logic error in a script, an exception occurs (such as a ZeroDivisionError from an attempt to divide by 0), so Python displays a xe "traceback"traceback, then terminates the script.
C) A fatal error in interactive mode terminates only the current snippet. Then IPython waits for your next input.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) Python provides three types of xe "selection statement"selection statements that execute code based on a condition-any expression that evaluates to either xe "keyword:True"xe "True"True or xe "keyword:False"xe "False"False.
B) The if...else statement performs an action if a condition is True or performs a different action if the condition is False.
C) Anywhere a single action can be placed, a group of actions can be placed.
D) The if…elif…else statement is called a double-selection statement because it selects one of two different actions (or groups of actions).
Question
Python provides two xe "iteration statement"iteration statements-________ and ________:

A) do while and for
B) while and for each
C) do while and for each
D) while and for
Question
Which of the following statements a), b) or c) is false?

A) You can solve any computing problem by executing a series of actions in a specific order.
B) An algorithm is a xe "procedure for solving a problem"procedure for solving a problem in terms of the actions to execute, and the order in which these actions execute.
C) Program control specifies the order in which statements (actions) execute in a program.
D) All of the above statements are true.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/20
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 3: Control Statements and Program Development  
1
Which of the following statements is false?

A) Each sequence has an iterator.
B) The for statement uses the iterator "behind the scenes" to get each consecutive item until there are no more to process.
C) The iterator is like a bookmark-it always knows where it is in the sequence, so it can return the next item when it's called upon to do so.
D) Lists are unordered and a list's items are mutable.
D
2
________ is an informal English-like language for "thinking out" algorithms.

A) Code
B) Pseudocode
C) Python
D) Quasicode
B
3
What does the following for statement print? for counter in range(10):
Print(counter, end=' ')

A) It doesn't run because it's syntactically incorrect.
B) 0 1 2 3 4 5 6 7 8 9 10
C) 1 2 3 4 5 6 7 8 9
D) 0 1 2 3 4 5 6 7 8 9
D
4
What does the following line of code display? print(10, 20, 30, sep=', ')

A) 102030
B) 10,20,30
C) 10 20 30
D) 10, 20, 30
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements is false?

A) The while statement allows you to repeat one or more actions while a condition remains True.
B) The following code sets product to the first power of 2 larger than 64: product = 2
While product < 64:
Product = product * 2
C) Something in a while statement's suite must ensure that the condition eventually becomes False. Otherwise, a logic error called an infinite loop occurs.
D) In applications executed from a Terminal, Command Prompt or shell, type Ctrl + c or control + c (depending on your keyboard) to terminate an infinite loop.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following statements a), b) or c) is false?

A) Augmented assignments xe "abbreviating an assignment expression"abbreviate assignment expressions in which the same variable name appears on the left and right of the assignment's =, as total does in: for number in [1, 2, 3, 4, 5]:
Total = total + number
B) The following code re-implements the for statement in Part (a) using an addition augmented assignment (+=) statement: for number in [1, 2, 3, 4, 5]:
Total += number
C) The statement f = f ** 3 may be replaced by the more concise augmented assignment statement f *= 3.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
7
The most important flowchart symbol is the ________, which indicates that a decision is to be made, such as in an if statement.

A) rectangle
B) flowline
C) xe "decision symbol"diamond
D) small circle
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements a), b) or c) is false?

A) You form each Python program by combining as many control statements of each type as you need for the algorithm the program implements.
B) With Single-entry/single-exit (one way in/one way out) control statements, the exit point of one connects to the entry point of the next. This is similar to the way a child stacks building blocks-hence, the term control-statement stacking.
C) You can construct any Python program from only six different forms of control (sequential execution, and the if, if…else, if…elif…else, while and for statements). You combine these in only two ways (control-statement stacking and control-statement nesting). This is the essence of simplicity.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following statements is false?

A) The xe "decision symbol"decision (diamond) symbol contains a condition that can be either True or False.
B) The diamond flowchart symbol has three xe "flowline"flowlines emerging from it.
C) One flowline emerging from the diamond flowchart symbol indicates the direction to follow when the condition in the symbol is True. This points to the action (or group of actions) that should execute.
D) Another flowline emerging from the diamond flowchart symbol indicates the direction to follow when the condition is False. This skips the action (or group of actions).
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements is false?

A) The sequence to the right of the for statement's keyword in must be an iterable.
B) An iterable is an object from which the for statement can take one item at a time until no more items remain.
C) One of Python's most common iterable sequences is the list, which is a comma-separated collection of items enclosed in square brackets ([ and ]).
D) The following code totals five integers in a list: total = 0
For number in [2, -3, 0, 17, 9]:
Total + number
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements is false?

A) Sometimes the suites in an if…else statement assign different values to a variable, based on a condition, as in: grade = 87
If grade >= 60:
Result = 'Passed'
Else:
Result = 'Failed'
B) You can replace if…else statements like the one above using a concise conditional expression: result = ('Passed' if grade >= 60 else 'Failed')
C) The parentheses in a conditional expression are required; otherwise, a syntax error occurs.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following statements is false?

A) Any expression may be evaluated as True or False.
B) A condition which evaluates to a nonzero value is considered to be True, and a condition which evaluates to a value of zero is considered to be False.
C) Strings containing characters are True and xe "empty:string"empty strings ('', "" or """""") are False.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following statements a), b) or c) is false?

A) The following code shows two statements in the else suite of an if…else statement: grade = 49
If grade >= 60:
Print('Passed')
Else:
Print('Failed')
Print('You must take this course again')
B) In the code in Part (a), grade is less than 60, so both statements in the else's suite execute.
C) In the code of Part (a), even if you do not indent the else suite's second print statement, it's still in the else's suite. So, the code runs correctly.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements is false?

A) Built-in function print displays its argument(s), then moves the cursor to the next line. You can change this behavior with the argument end, as in print(character, end=' ')
B) Python calls end a keyword argument, and end is a Python keyword.
C) The end keyword argument is optional. If you do not include it, print uses a newline ('\n') by default.
D) Keyword arguments are sometimes called named arguments.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
15
Various Python statements enable you to specify that the next statement to execute may be other than the next one in sequence. This is called ________ and is achieved with Python xe "control statement"control statements.

A) xe "transfer of control"transfer of control
B) alternate execution
C) spread execution
D) None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following statements is false?

A) xe "indentation"Indenting a suite is required; otherwise, an xe "IndentationError"IndentationError syntax error occurs.
B) If you have more than one statement in a suite, those statements do not need to have the same indentation.
C) Sometimes error messages may not be clear. The fact that Python calls attention to the line is often enough for you to figure out what's wrong.
D) Programs that are not uniformly xe "indentation"indented are hard to read.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following statements a), b) or c) is false?

A) With a nonfatal xe "logic error"logic error, an IPython interactive session terminates.
B) For a fatal logic error in a script, an exception occurs (such as a ZeroDivisionError from an attempt to divide by 0), so Python displays a xe "traceback"traceback, then terminates the script.
C) A fatal error in interactive mode terminates only the current snippet. Then IPython waits for your next input.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements is false?

A) Python provides three types of xe "selection statement"selection statements that execute code based on a condition-any expression that evaluates to either xe "keyword:True"xe "True"True or xe "keyword:False"xe "False"False.
B) The if...else statement performs an action if a condition is True or performs a different action if the condition is False.
C) Anywhere a single action can be placed, a group of actions can be placed.
D) The if…elif…else statement is called a double-selection statement because it selects one of two different actions (or groups of actions).
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
19
Python provides two xe "iteration statement"iteration statements-________ and ________:

A) do while and for
B) while and for each
C) do while and for each
D) while and for
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following statements a), b) or c) is false?

A) You can solve any computing problem by executing a series of actions in a specific order.
B) An algorithm is a xe "procedure for solving a problem"procedure for solving a problem in terms of the actions to execute, and the order in which these actions execute.
C) Program control specifies the order in which statements (actions) execute in a program.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 20 flashcards in this deck.