Chapter 2 Input, Processing, and Output Flashcards
A ___ error does not prevent the program from running, but causes it to produce incorrect results.
a. syntax
b. hardware
c. logic
d. fatal
logic
Chapter 2 (page 32)
A logic error is a mistake that does not prevent the program from running, but causes it to produce incorrect results. (Mathematical mistakes are common causes of logic errors.)
A ___ is a single function that the program must perform in order to satisfy the customer.
a. task
b. software requirement
c. prerequisite
d. predicate
software requirement
Chapter 2 (page 33)
A software requirement is simply a single task that the programmer must perform in order to satisfy the customer. Once the customer agrees that the list of requirements is complete, the programmer can move to the next phase.
A(n) ___ is a set of well-defined logical steps that must be taken to perform a task.
a. logarithm
b. plan of action
c. logic schedule
d. algorithm
algorithm
Chapter 2 (page 33)
An algorithm is a set of well-defined logical steps that must be taken to perform a task. Steps in algorithm are sequentially ordered, step 1 should be performed before step 2, and so on.
An informal language that has no syntax rules and is not meant to be compiled or executed is called ___.
a. faux code
b. pseudocode
c. Python
d. a flowchart
pseudocode
Chapter 2 (page 34)
Word “pseudo” means fake, so pseudocode is fake code. It is an informal language that has no syntax rules and is not meant to be compiled or executed. Programmers use pseudocode to create models, or “mock-ups” of programs.
A ___ is a diagram that graphically depicts the steps that take place in a program.
a. flowchart
b. step chart
c. code graph
d. program graph
flowchart
Chapter 2 (page 34)
A flowchart is a diagram that graphically depicts the steps that take place in a program.
A ___ is a sequence of characters.
a. char sequence
b. character collection
c. string
d. text block
string
Chapter 2 (page 37)
In programming terms, a sequence of characters that is used as data is called string. When a string appears in the actual code of a program, it is called a string literal. In Python code, string literals must be enclosed in quote marks.
A ___ is a name that references a value in the computer’s memory.
A. variable
b. register
c. RAM slot
d. byte
variable
Chapter 2 (page 40)
A variable is a name that represents a value in the computer’s memory. For example, a program that calculates the sales tax on a purchase might use the variable name ‘tax’ to represent that value in memory.
When a variable represents a value in the computer’s memory, we say that the variable ‘references’ the value.
A ___ is any hypothetical person using a program and providing input for it.
a. designer
b. user
c. guinea pig
d. test subject
Chapter 2 (page )
A string literal in Python must be enclosed in ___.
a. parentheses
b. single-quotes
c. double-quotes
d. either single-quotes or double-quotes
either single quotes or double quotes
Chapter 2 (page 37)
In Python, you can enclose string literals in a set of single-quote marks ( ‘ ) or a set of double-quote marks ( “ )
Short notes placed in different parts of a program explaining how those parts of the program work are called ___.
a. comments
b. reference manuals
c. tutorials
d. external documentation
comments
Chapter 2 (page 39)
Comments are short notes placed in different parts of a program, explaining how those parts of the program work. Although comments are a critical part of a program, they are ignored by the Python interpreter. Comments are intended for any person reading a program’s code, not the computer.
A(n) ___ makes a variable reference a value in the computer’s memory.
a. variable declaration
b. assignment statement
c. math expression
d. string literal
assignment statement
Chapter 2 (page 40)
You use an assignment statement to create a variable and make it reference a piece of data. Here is an example of an assignment statement:
age = 25
An assignment statement is written in the following general format:
variable = expression
This symbol marks the beginning of a comment in Python.
a. &
b. *
c. **
d. #
#
Chapter 2 (page 39)
In Python, you begin a comment with the # character. When the Python interpreter sees a # character, it ignores everything from that character to the end of the line.
Which of the following statements will cause an error?
a. x = 17
b. 17 = x
c. x = 99999
d. x = ‘ 17 ‘
17 = x
Chapter 2 (page 42)
In an assignment statement, the variable that is receiving the assignment must appear on the left side of the operator. An error occurs if the item on the left side of the = operator is not a variable
In the expression 12 + 7, the values on the right and left of the + symbol are called ___.
a. operands
b. operators
c. arguments
d. math expressions
Chapter 2 (page)
This operator performs integer division.
a. / /
b. %
c. **
d. /
/ /
Chapter 2 (page 54)
/ / Integer Division
Divides one number by another and gives the result as a whole number.
5 // 2 = 2
/ Division
Divides one number by another and gives the result as a floating-point number.
5 / 2 = 2.5
This is an operator that raises a number to a power.
a. %
b. *
c. **
d. /
- *
Chapter 2 (page 54)
** Exponent
Raises a number to a power.
This operator performs division, but instead of returning the quotient it returns the remainder.
a. %
b. *
c. **
d. /
%
Chapter 2 (page 54)
% Remainder
Divides one number by another and gives the remainder.
Suppose the following statement is in a program:
price = 99.0. After this statement executes, the price variable will reference a value of which data type?
a. int
b. float
c. currency
d. str
float
Chapter 2 (page 47)
A numeric literal that is written with a decimal point is considered a float. Examples are 1.5, 3.14159 , and 99.0
Which built-in function can be used to read input that has been typed on the keyboard?
a. input ( )
b. get_input ( )
c. read_input ( )
d. keyboard ( )
input ( )
Chapter 2 (page 49)
The input function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program. You normally use the input function in an assignment statement that follows this general format:
variable = input(prompt)
Which built-in function can be used to convert an int value to a float?
a. int_to_float ( )
b. float ( )
c. convert ( )
d. int ( )
int ( )
Chapter 2 (page 51) int(item) You pass an argument to the int( ) function and it returns the argument's value converted to an int.
A magic number is ___.
a. a number that is mathematically undefined
b. an unexplained value that appears in a program’s code
c. a number that cannot be divided by 1
d. a number that causes a computer to crash
an unexplained value that appears in a program’s code
Chapter 2 (page 73)
A magic numbers can be problematic, for a number of reasons. It can be difficult for someone reading the code to determine the purpose of of the number. If the magic number is used in multiple places in the program, it can take painstaking effort to change the number in each location should the need arise. Third, you take the risk of making a typographical mistake each time you type the magic number in the program’s code.
A ___ is a name that represents a value that does not change during the program’s execution.
a. named literal
b. named constant
c. variable signature
d. key term
named constant
Chapter 2 (page 73)
Programmers must be careful not to make syntax errors when writing pseudocode programs. True or False?
False
Chapter 2 (page 34)
Programmers use pseudocode to create models, or “mock-ups” of programs. Programmers don’t have to worry about syntax errors while writing pseudocode, they can focus all of their attention on the program’s design.
In a math expression, multiplication and division take place before addition and subtraction. True or False?
Chapter 2 (page )