Chapter 2 Review Questions
Chapter 2 Review Questions
1. A __________ error does not prevent the program from running, but causes it to produce
incorrect results.
a. syntax
b. hardware
c. logic d. fatal
2. 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
3. A(n)__________isasetofwell-definedlogicalstepsthatmustbetakentoperformatask. a. logarithm
b. plan of action c. logic schedule d. algorithm
4. 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
5. 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
6. A __________ is a sequence of characters. a. char sequence
b. character collection
c. string
d. text block
7. A __________ is a name that references a value in the computer’s memory. a. variable
b. register
c. RAM slot d. byte
8. A __________ is any hypothetical person using a program and providing input for it. a.
designer
b. user
c. guinea pig d. test subject
9. A string literal in Python must be enclosed in __________. a. parentheses.
b. single-quotes.
c. double-quotes.
d. either single-quotes or double-quotes.
10. 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
11. 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
3. Write assignment statements that perform the following operations with the variables a, b, and
c:
a. Adds 2 to a and assigns the result to b
b. Multiplies b times 4 and assigns the result to a c. Divides a by 3.14 and assigns the result to b
d. Subtracts 8 from b and assigns the result to a
4. Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z =
2. What value will be stored in result after each of the following statements execute?
a. result=x+y
b.result=z * 2 c. result=y / x d.result=y – z e. result=w // z
5. Write a Python statement that assigns the sum of 10 and 14 to the variable total.
6. Write a Python statement that subtracts the variable down_payment from the variable
total and assigns the result to the variable due.
7. Write a Python statement that multiplies the variable subtotal by 0.15 and assigns
the result to the variable total.
8. What would the following display?
a= 5
b= 2
c= 3
result = a + b * c print(result)
9. What would the following display?
num = 99 num = 5 print(num)
10. Assume the variable sales references a float value. Write a statement that displays the value
rounded to two decimal points.
11. Assume the following statement has been executed:
number = 1234567.456
Write a Python statement that displays the value referenced by the number variable formatted as
1,234,567.5
12. What will the following statement display?
print('George', 'John', 'Paul', 'Ringo', sep='@')
13. Write a turtle graphics statement that draws a circle with a radius of 75 pixels.
14. Write the turtle graphics statements to draw a square that is 100 pixels wide on each side and
filled with the color blue.
15. Write the turtle graphics statements to draw a square that is 100 pixels wide on each side and
a circle that is centered inside the square. The circle’s radius should be 80 pixels. The circle
should be filled with the color red. (The square should not be filled with a color.)