Course: Intermediate Web Programming (25436)

Q: Which of these is associated with a specific file and provides a way for the program to work with that file?
- Filename
- Extension
- File object
- File variable
A: File object

Q: What do you call the process of retrieving data from a file?
- Retrieving data
- Reading data
- Input data
- Get data
A: Reading data

Q: What happens when a piece of data is written to a file?
- Data is copied from a variable in RAM to a file.
- Data is copied from a variable in the program to a file.
- Data is copied from the program to a file.
- Data is copied from a file object to a file.
A: Data is copied from a variable in RAM to a file.

Q: Which step creates a connection between a file and a program?
- Open the file.
- Read the file.
- Process the file.
- Close the file.
A: Open the file.

Q: How many types of files are there?
- One
- Two
- Three
- Four
A: Two

Q: A(n) _____ access file is also known as a direct access file.
- sequential
- random
- numbered
- text
A: random

Q: What type of file access jumps directly to any piece of data in a file without reading the data that came before it?
- Sequential	
- Random	
- Number	
- Text
A: Random	

Q: Which one of the following mode specifiers will open a file but will not let you change the file or write to it?
- ‘w’
- ‘r’
- ‘a’
- 'e'
A: ‘r’

Q: Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?
- ‘w’
- ‘r’
- ‘a’
- ‘e’
A: ‘w’

Q: Assume that the customer file references a file object, and the file was opened using the ‘w’ mode specifier. How would you write the string ‘Mary Smith’ to the file?
- customer_file.write(‘Mary Smith’)
- customer.write(‘w’,‘Mary Smith’)
- customer.input(‘Mary Smith’)
- customer.write(‘Mary Smith’)
A: customer.write(‘Mary Smith’)

Q: When a file has been opened using the ‘r’ mode specifier, which method will return the file’s contents as a string?
- write
- input
- get
- read
A: read

Q: Which method could be used to strip specific characters from the end of a string?
- estrip
- rstrip
- strip
- remove
A: rstrip

Q: A(n) _____ method could be used to convert a numeric value to a string?
- str
- value
- num
- chr
A: str

Q: Which method will return an empty string when it has attempted to read beyond the end of a file?
- read	
- getline	
- input	
- readline	
A: readline	

Q: What statement can be used to handle some of the run-time errors in a program?
- exception statement	
- try statement	
- try/except statement	
- exception handler statement	
A: try/except statement	

Q: If a file with the specified name already exists when the file is opened, and the file is opened in 'w' mode, then an alert will appear on the screen.
- True
- False
A: False

Q: When a piece of data is read from a file, it is copied from the file into the program.
- True
- False
A: False

Q: Closing a file disconnects the communication between the file and the program.
- True
- False
A: True

Q: Python allows the programmer to work with text and number files.
- True
- False
A: False

Q: In Python, there is nothing that can be done if the program tries to access a file to read that does not exist.
- True
- False
A: False

Q: The ZeroDivisionError exception is raised when the program attempts to perform a division by zero.
- True
- False
A: True

Q: An exception handler is a piece of code that is written using the try/except statement.
- True
- False
A: True

Q: If the last line in a file is not terminated with a \n, the readline method will return the line without a \n.
- True
- False
A: True

Q: Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.
- True
- False
A: True

Q: It is possible to create a while loop that determines when the end of a file has been reached.
- True
- False
A: True

Q: When a program needs to save data for later use, it writes the data in a(n) _______________.
A: file

Q: Programmers usually refer to the process of _______________ data in a file as “writing data to” the file.
A: saving

Q: The term ___________ file is used to describe a file to which data is written.
A: output

Q: The term __________ file is used to describe a file from which the program gets data.
A: input

Q: A(n) ____________ file contains data that has been encoded as text, using a scheme such as ASCII.
A: text

Q: A(n) __________ file contains data that has not been converted to text.
A: binary

Q: A(n) _______________ access file retrieves data from the beginning of the file to the end of the file.
A: sequential

Q: A filename _______________ is a short sequence of characters that appear at the end of a filename preceded by a period.
A: extension

Q: A(n) ___________ gives information regarding the line number(s) that caused an exception.
A: traceback

Q: A(n) __________ includes one or more statements that can potentially raise an exception.
A: try block

Q: The Python library functions that are built into the Python _____ can be used by simply calling the function.
- code
- compiler
- linker
- interpreter
A: interpreter

Q: Python comes with _____ functions that have been already prewritten for the programmer.
- standard
- library
- custom
- built-in
A: standard

Q: Which of the following statements causes the interpreter to load the contents of the random module into memory?
- load random
- import random
- upload random
- download random
A: import random

Q: Which one of the following will assign a random number in the range of 1 through 50 to the variable number?
- random(1,50) = number
- number = random.randint(1, 50)
- randint(1, 50) = number
- number = random(range(1, 50))
A: number = random.randint(1, 50)

Q: What is the result of the following statement? x = random.randint(5, 15) * 2
- A random integer from 5 to 15, multiplied by 2, assigned to the variable x
- A random integer from 5 to 15 assigned to the variable x
- A random integer from 5 to 15, selected in 2 steps, assigned to the variable x
- A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
A: A random integer from 5 to 15, multiplied by 2, assigned to the variable x

Q: What type of value is returned by the functions random and uniform?
- integer
- number
- float
- double
A: float

Q: In a value-returning function, the value of the expression that follows the key word _____ will be sent back to the part of the program that called the function.
- def
- return
- sent
- result
A: return

Q: What type of function can be used to determine whether a number is even or odd?
- even
- odd
- math
- Boolean
A: Boolean

Q: The Python standard library’s _____ module contains numerous functions that can be used in mathematical calculations.
- math
- string
- random
- number
A: math

Q: The _______ functions returns the largest integer that is less than or equal to x?
- floor
- ceil
- lesser
- greater
A: floor

Q: What makes it easier to reuse the same code in more than one program?
- Mods
- Procedures
- Modules
- Functions
A: Modules

Q: In a menu-driven program, what statement is used to determine and carry out the user’s desired action?
- if-else
- if-elif-else
- while
- for
A: if-elif-else

Q: A value-returning function is _____.
- a single statement that perform a specific task
- called when you want the function to stop
- a function that will return a value back to the part of the program that called it
- a function that receives a value when it is called
A: a function that will return a value back to the part of the program that called it

Q: What does the following statement mean? num1, num2 = get_num()
- The function get_num() is expected to return a value each for num1 and num2.	
- The function get_num() is expected to return a value and assign it to num1 and num2.	
- Statement will cause a syntax error.	
- Statement will cause a run-time error.	
A: The function get_num() is expected to return a value each for num1 and num2.	

Q: Given the following function definition, what would the statement print magic(5) display?
def magic(num):
return num + 2 * 10
- 70	
- 25	
- Statement will cause a syntax error.	
- Statement will cause a run-time error.	
A: 25	

Q: A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program.
- True
- False
A: True

Q: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
- True
- False
A: True

Q: Unlike other languages, in Python, the number of values a function can return is limited to one.
- True
- False
A: False

Q: In Python, one can have a list of variables on the left side of the assignment operator.
- True
- False
A: True

Q: In Python, there is no restriction on the name of a module file.
- True
- False
A: False

Q: The randrange function returns a randomly selected value from a specific sequence of numbers.
- True
- False
A: True

Q: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
- True
- False
A: False

Q: In a menu-driven program, a loop structure is used to determine the menu item the user selected.
- True
- False
A: False

Q: The math function, atan(x), returns one tangent of x in radians.
- True
- False
A: False

Q: The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
- True
- False
A: True

Q: Functions in the standard library are stored in files that are known as _______________.
A: modules

Q: The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
A: black box

Q: To refer to a function in a module, in our program we have to use the _______________ notation.
A: dot

Q: A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
A: return

Q: The _______________ chart is an effective tool that programmers use for designing and documenting functions.
A: IPO

Q: The ‘P’ in the acronym IPO refers to _______________.
A: processing

Q: In Python, a module’s file name should end in _______________.
A: .py

Q: A(n) _______________ program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.
A: menu-driven

Q: The approach of _______________ makes the program easier to understand, test, and maintain.
A: modularization

Q: The return values of the trigonometric functions in Python are in _______________.
A: radians

Q: What is the disadvantage of coding in one long sequence structure?
- Duplicated code makes the program faster to write.
- Writing a long sequence of statements is error prone.
- If parts of the duplicated code have to be corrected, the correction has to be made many times.
- It does not make use of decision structures.
A: If parts of the duplicated code have to be corrected, the correction has to be made many times.

Q: What type of loop structure repeats the code a specific number of times?
- Condition-controlled loop
- Number-controlled loop
- Count-controlled loop
- Boolean-controlled loop
A: Count-controlled loop

Q: What type of loop structure repeats the code based on the value of the Boolean expression?
- Condition-controlled loop
- Number-controlled loop
- Count-controlled loop
- Boolean-controlled loop
A: Condition-controlled loop

Q: What is the format for the while clause in Python?
- while condition
- while condition :
- while condition statement
- while condition : statement
A: while condition :

Q: What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)
- 2, 3, 4, 5, 6, 7, 8, 9
- 2, 5, 8
- 2, 4, 6, 8
- 1, 3, 5, 7, 9
A: 2, 4, 6, 8

Q: What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)
- 1, 2, 3, 4
- 0, 1, 2, 3, 4
- 1, 2, 3
- 0, 1, 2, 3
A: 0, 1, 2, 3

Q: The variable used to keep the running total is called a(n) _____.
- Accumulator
- Total
- running total
- grand total
A: Accumulator

Q: What is not an example of an augmented assignment operator?
- *=
- /=
- -=
- <=
A: <=

Q: _____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.
- Input validation
- Correcting data
- Data validation
- Correcting input
A: Input validation

Q: The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.
- priming read
- first input
- loop set read
- loop validation
A: priming read

Q: What is the structure that causes a statement or a set of statements to execute repeatedly?
- Sequence
- Decision
- Module
- Repetition

12 When will the following loop terminate? while keep_on_going != 999 :
a. When keep_on_going refers to a value less than 999
b. When keep_on_going refers to a value greater than 999
*c. When keep_on_going refers to a value equal to 999
d. When keep_on_going refers to a value not equal to 999
A: Repetition

12 When will the following loop terminate? while keep_on_going != 999 :
a. When keep_on_going refers to a value less than 999
b. When keep_on_going refers to a value greater than 999
*c. When keep_on_going refers to a value equal to 999
d. When keep_on_going refers to a value not equal to 999

Q: In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.
- sequence
- variable
- value
- list
A: list

Q: In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.
- target variable	
- loop variable	
- for variable	
- count variable	
A: target variable	

Q: Which of the following represents an example to calculate the sum of the numbers (accumulator)?
- total + number = total	
- number += number	
- total += number	
- total = number	
A: total += number	

Q: Reducing duplication of code is one of the advantages of using a loop structure.
- True
- False
A: True

Q: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.
- True
- False
A: True

Q: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
- True
- False
A: True

Q: The first line in the while loop is referred to as the condition clause.
- True
- False
A: False

Q: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
- True
- False
A: False

Q: Both of the following for clauses would generate the same number of loop iterations:
for num in range(4):
for num in range(1,5):
- True
- False
A: True

Q: The integrity of a program’s output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data.
- True
- False
A: True

Q: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.
- True
- False
A: False

Q: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.
- True
- False
A: True

Q: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.
- True
- False
A: True

Q: A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
A: repetition

Q: A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition is true.
A: condition

Q: The while loop is known as a(n) _______________ loop because it tests conditions before performing an iteration.
A: pretest

Q: A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false.
A: infinite

Q: In Python, you would use the _______________ statement to write a count-controlled loop.
A: for

Q: A(n) _______________ total is a sum of numbers that accumulates with each iteration of a loop.
A: running

Q: A(n) _______________ is a special value that marks the end of a sequence of items.
A: sentinel

Q: The acronym _______________ refers to the fact that the computer cannot tell the difference between good data and bad data.
A: GIGO

Q: A(n) _______________ validation loop is sometimes called an error trap or an error handler.
A: input

Q: The _______________ function is a built-in function that generates a list of integer values.
A: range

Q: A(n) _____ structure is a logical design that controls the order in which a set of statements execute.
- function
- control
- sequence
- iteration
A: control

Q: The decision structure that has two possible paths of execution is known as _____.
- single alternative
- double alternative
- dual alternative
- two alternative
A: dual alternative

Q: Multiple Boolean expressions can be combined by using a logical operator to create _____ expressions.
- sequential
- logical
- compound
- mathematical
A: compound

Q: When using the _____ operator, one or both subexpressions must be true for the compound expression to be true.
- Or
- And
- Not
- Maybe
A: Or

Q: Which logical operators perform short-circuit evaluation?
- or, not
- not, and
- or, and
- and, or, not
A: or, and

Q: Which of the following is the correct if clause to determine whether y is in the range 10 through 50?
- if 10 < y or y > 50
- if 10 > y and y < 50
- if y > 10 and y < 50
- if y > 10 or y < 50
A: if y > 10 and y < 50

Q: A Boolean variable can reference one of two values: _____.
- yes or no
- true or false
- T or F
- Y or N
A: true or false

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8?
x < y or z > x
- true
- false
- 8
- 5
A: true

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y and z > x
- true
- false
- 8
- 5
A: false

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? not (x < y or z > x) and y < z
- true
- false
- 8
- 5
A: false

Q: What does the following expression mean? x <= y
- x is less than y
- x is less than or equal to y
- x is greater than y
- x is greater than or equal to y
A: x is less than or equal to y

Q: Which of the following is the correct if clause to use to determine whether choice is other than 10?
- if choice != 10:
- if choice != 10
- if choice <> 10:
- if choice <> 10
A: if choice != 10:

Q: When using the _____ operator, both subexpressions must be true for the compound expression to be true.
- or
- and
- not
- maybe
A: and

Q: In Python, the _____ symbol is used as the not-equal-to operator.
- ==	
- <>	
- <=	
- !=	
A: !=	

Q: In Python the _____ symbol is used as the equality operator.
- ==	
- =	
- >=	
- <=	
A: ==	

Q: The if statement causes one or more statements to execute only when a Boolean expression is true.
- True
- False
A: True

Q: The Python language is not sensitive to block structuring of code.
- True
- False
A: False

Q: Python allows you to compare strings, but it is not case sensitive.
- True
- False
A: False

Q: Nested decision structures are one way to test more than one condition.
- True
- False
A: True

Q: Python uses the same symbols for the assignment operator and the equality operator.
- True
- False
A: False

Q: The not operator is a unary operator and it must be a compound expression.
- True
- False
A: False

Q: Short-circuit evaluation is performed with the not operator.
- True
- False
A: False

Q: Expressions that are tested by the if statement are called Boolean expressions.
- True
- False
A: True

Q: Decision structures are also known as selection structures.
- True
- False
A: True

Q: An action in a single alternative decision structure is performed only when the condition is true.
- True
- False
A: True

Q: The _______________ statement is used to create a decision structure.
A: if

Q: In flowcharting, the _______________ symbol is used to represent a Boolean expression.
A: diamond

Q: A(n) _______________ decision structure provides only one alternative path of execution.
A: single alternative

Q: In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true.
A: conditionally

Q: A(n) _______________ operator determines whether a specific relationship exists between two values.
A: relational

Q: A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false.
A: if-else

Q: 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.
A: if-elif-else

Q: The logical _______________ operator reverses the truth of a Boolean expression.
A: not

Q: Boolean variables are commonly used as _______________ to indicate whether a specific condition exists.
A: flags

Q: A(n) _______________ expression is made up of two or more Boolean expressions.
A: compound

Q: What is a group of statements that exists within a program for the purpose of performing a specific task?
- function
- subtask
- procedure
- subprogram
A: function

Q: The first line in the function definition is known as the function _____.
- header
- block
- return
- parameter
A: header

Q: The _____ design technique can be used to break down an algorithm into functions.
- subtask
- block
- top-down
- simplification
A: top-down

Q: A set of statements that belong together as a group and contribute to the function definition is known as a(n) _____.
- header
- block
- return
- parameter
A: block

Q: A(n) _____ chart is also known as a structured chart.
- flow
- data
- hierarchy
- organizational
A: hierarchy

Q: A(n) _____ variable is created inside a function.
- global
- constant
- defined
- local
A: local

Q: The _____ of a local variable is the function in which the variable is created.
- global
- defined
- local
- scope
A: scope

Q: A(n) _____ is any piece of data that is passed into a function when the function is called.
- global
- argument
- scope
- parameter
A: argument

Q: A(n) _____ is a variable that receives an argument that is passed into a function.
- global
- argument
- scope
- parameter
A: parameter

Q: The _____ argument specifies which parameter the argument should be passed into.
- keyword
- local
- global
- string
A: keyword

Q: A(n) ____ variable is accessible to all the functions in a program file.
- keyword
- local
- global
- string
A: global

Q: A(n) _____ constant is a global name that references a value that cannot be changed.
- keyword
- local
- global
- string
A: global

Q: When a function is called by its name, then it is _____.
- executed
- located
- defined
- exported
A: executed

Q: It is recommended that programmers should avoid using _____ variables in a program when possible.
- local
- global
- string global
- keyword
A: global

Q: A variable’s _____ is the part of a program in which the variable may be accessed.
- global		
- argument	
- scope	
- local	
A: scope	

Q: Python function names follow the same rules for naming variables.
- True
- False
A: True

Q: The function header marks the beginning of the function definition.
- True
- False
A: True

Q: A function definition specifies what a function does and causes the function to execute.
- True
- False
A: False

Q: The hierarchy chart shows all the steps that are taken inside a function.
- True
- False
A: False

Q: A local variable can be accessed from anywhere in the program.
- True
- False
A: False

Q: Different functions can have local variables with the same names.
- True
- False
A: True

Q: Python allows for passing multiple arguments to a function.
- True
- False
A: True

Q: To assign a value to a global variable in a function, the global variable must first be declared in the function.
- True
- False
A: True

Q: The value assigned to a global constant can be changed in the mainline logic.
- True
- False
A: False

Q: One of the reasons not to use global variables is that it makes a program hard to debug.
- True
- False
A: True

Q: The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
A: divide and conquer

Q: The code for a function is known as a function _______________.
A: definition

Q: A function header begins with the keyword _______________ followed by the name of the function.
A: def

Q: The main function contains a program’s _______________ logic, which is the overall logic of the program.
A: mainline

Q: In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
A: rectangle

Q: The top-down design breaks down the overall task of the program into a series of _______________.
A: subtasks

Q: A(n) _______________ chart is a visual representation of the relationships between functions.
A: hierarchy

Q: Arguments are passed by _______________ to the corresponding parameter variables in the function.
A: position

Q: A variable is visible only to statements in the variable’s _______________.
A: scope

Q: What type of error produces incorrect results but does not prevent the program from running?
- syntax
- logic
- grammatical
- human
A: logic

Q: The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.
- five
- four
- three
- six
A: five

Q: What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?
- Flowchart
- Algorithm
- Code
- Pseudocode
A: Pseudocode

Q: A(n) _____ is a diagram that graphically depicts the steps that take place in a program.
- flowchart
- algorithm
- code
- pseudocode
A: flowchart

Q: The _____ 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.
- input
- output
- eval_input
- string_input
A: input

Q: The line continuation character is a _____.
- #
- %
- &
- \
A: \

Q: Which mathematical operator is used to raise five to the second power in Python?
- /
- **
- ^
- ~
A: **

Q: In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.
- stop
- end
- separator
- newLine
A: end

Q: After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752
- int
- float
- str
- currency
A: float

Q: After executing the following statement, the variable price will reference the value _____. price = int(68.549)
- 68
- 69
- 68.55
- 68.54
A: 68

Q: The output of the following print statement is: print ‘I\’m ready to begin’
- Im ready to begin
- I\’m ready to begin
- I’m ready to begin
- ‘I\’m ready to begin’
A: I’m ready to begin

Q: If value1 is 2.0 and value2 is 12, what is the output of the following command?
print(value1 * value2)
- 24
- value1 * value2
- 24.0
- 2.0 * 12
A: 24.0

Q: The _____ built-in function is used to read a number that has been typed on the keyboard.
- input()
- read()
- get()
- keyboard()
A: input()

Q: What is the output of the following print statement?
print(‘The path is D:\\sample\\test.’)
- ‘The path is D:\\sample\\test.’
- The path is D:\\sample\\test.
- The path is D\\sample\\test.
- The path is D:\sample\test.
A: The path is D:\sample\test.

Q: What symbol is used to mark the beginning and end of a string?
- Slash
- Asterisk
- Quotation
- Comma
A: Quotation

Q: Comments in Python begin with the # character.
- True
- False
A: True

Q: When using the camelCase naming convention, the first word of the variable name is written in lowercase letters and the first character of the second and subsequent words are written in uppercase letters.
- True
- False
A: True

Q: According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.
- True
- False
A: False

Q: Python allows programmers to break a statement into multiple lines.
- True
- False
A: True

Q: Python formats all floating-point numbers to two decimal places when outputting using the print statement.
- True
- False
A: False

Q: A flowchart is a tool that programmers use to design programs.
- True
- False
A: True

Q: In Python, math expressions are evaluated from left to right, no matter what the operators are.
- True
- False
A: False

Q: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.
- True
- False
A: True

Q: The \t escape character causes the output to skip over to the next horizontal tab.
- True
- False
A: True

Q: _______________ are notes of explanation that document lines or sections of a program.
A: Comments

Q: The % symbol is the remainder operator and it is also known as the _______________ operator.
A: modulus

Q: A(n) _______________ character is a special character that is preceded with a backslash, appearing inside a string literal.
A: escape

Q: The _______________ specifier is a special set of characters that specify how a value should be formatted.
A: formatting

Q: The result of the expression 12.3 + 6.7 is _______________.
A: 19.0

Q: When applying the .3f formatting specifier to the following number, 76.15854, the result is _______________.
A: 76.159

Q: A(n) _______ is a single task that the program must perform in order to satisfy the customer.
A: software requirement

Q: A(n) ________ is a name that represents a value stored in the computer’s memory.
A: variable

Q: Python uses _______________ to categorize values in memory.
A: data types

Q: When the + operator is used with two strings, it performs string _______________.
A: concatenation

Q: Programs are commonly referred to as _____.
- system software
- software
- application software
- utility programs
A: software

Q: Which of the following is considered to be the world’s first programmable electronic computer?
- IBM
- DELL
- ENIAC
- GATEWAY
A: ENIAC

Q: Where does a computer store a program and the data that the program is working with while the program is running?
- Main memory
- CPU
- Disk
- Microprocessor
A: Main memory

Q: Which one of the following is not a microprocessor manufacturing company?
- Intel
- Dell
- AMD
- Motorola
A: Dell

Q: What type of volatile memory is usually used only for temporary storage while running a program?
- ROM
- TMM
- RAM
- TVM
A: RAM

Q: Which computer language uses short words known as mnemonics for writing programs?
- Assembly
- Java
- Pascal
- Visual Basic
A: Assembly

Q: The process known as the _____ cycle is used by the CPU to execute instructions in a program.
- decode-fetch-execute
- decode-execute-fetch
- fetch-decode-execute
- fetch-execute-decode
A: fetch-decode-execute

Q: Which language from the following list is referred to as a low-level language?
- C++
- Assembly language
- JAVA
- Python
A: Assembly language

Q: The following is an example of an instruction written in which computer language? 10110000
- Assembly language
- JAVA
- Machine language
- C #
A: Machine language

Q: What is the encoding technique called that is used to store negative numbers in the computer’s memory?
- Unicode
- ASCII
- floating-point notation
- two’s complement
A: two’s complement

Q: The _____ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer memory.
- Unicode
- ASCII
- ENIAC
- twos complement
A: ASCII

Q: What is the largest value that can be stored in one byte?
- 255
- 128
- 8
- 65535
A: 255

Q: The smallest storage location in a computer’s memory is known as a _____.
- byte
- ketter
- switch
- bit
A: bit

Q: The disk drive is a secondary storage device that stores data by _____ encoding it onto circular disks.
- electrically
- magnetically
- digitally
- optically
A: magnetically

Q: Which of these is not a major component of a typical computer system?
- Central processing unit
- Main memory
- Operating system
- Secondary storage devices
A: Operating system

Q: A software developer is the person with the training to design, create, and test computer programs.
- True
- False
A: True

Q: A computer is a single device that performs different types of tasks for its users.
- True
- False
A: False

Q: The CPU is able to quickly access data stored at any random location in ROM.
- True
- False
A: False

Q: All programs are normally stored in ROM and loaded into RAM as needed for processing.
- True
- False
A: False

Q: The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.
- True
- False
A: True

Q: The CPU understands instructions written in a binary machine language.
- True
- False
A: True

Q: A bit that is turned off is represented by the value -1.
- True
- False
A: False

Q: The main reason for using secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.
- True
- False
A: True

Q: RAM is a volatile memory used for temporary storage while a program is running.
- True
- False
A: True

Q: The Python language uses a compiler, which is a program that both translates and executes the instructions in a high level language.
- True
- False
A: False

Q: A(n) _______________ is a set of instructions that a computer follows to perform a task.
A: program

Q: The term _______________ refers to all of the physical devices that a computer is made of.
A: hardware

Q: The _______________ is the part of a computer that actually runs programs and is the most important component in a computer.
A: central processing unit or CPU

Q: _______________ are small central processing unit chips.
A: Microprocessors

Q: Main memory is commonly known as _______________.
A: random-access memory or RAM

Q: _______________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer.
A: Secondary storage

Q: A disk drive stores data by _______________ encoding it onto a circular disk.
A: magnetically

Q: The disadvantages of a(n) _______________ are that it only holds small amounts of data, is slow to access data, and can be unreliable.
A: floppy disk

Q: The Python _______________ is a program that can read Python programming statements and execute them.
A: interpreter

Q: In _______________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.
A: script

Q: What are the data items in the list called?
- data
- elements
- items
- values
A: elements

Q: Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2)
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- [1, 3, 5, 7, 9]
- [2, 4, 6, 8]
- [0, 2, 4, 6, 8]
A: [0, 2, 4, 6, 8]

Q: What would you use if an element is to be removed from a specific index?
- del statement
- remove method
- index method
- slice method
A: del statement

Q: What is the first negative index in a list?
- 0	
- -1	
- -0	
- Size of the string or list minus one	
A: -1	

Q: What method can be used to place an item in the list at a specific index?
- append	
- index	
- insert	
- Add	
A: insert	

Q: What would be the value of the variable list after the execution of the following code?
list = [1, 2]
list = list * 3
- [1, 2] * 3	
- [3, 6]	
- [1, 2, 1, 2, 1, 2]	
- [[1, 2], [1, 2], [1, 2]]	
A: [1, 2, 1, 2, 1, 2]	

Q: What would be the value of the variable list after the execution of the following code?
list = [1, 2, 3, 4]
list[3] = 10
- [1, 2, 3, 10]	
- [1, 2, 10, 4]	
- [1, 10, 10, 10]	
- invalid code
A: [1, 2, 3, 10]	

Q: What method or operator can be used to concatenate lists?
- *	
- +	
- %	
- concat	
A: +	

Q: What would be the value of the variable list2 after the execution of the following code?
list1 = [1, 2, 3]
list2 = list1
list1 = [4, 5, 6]
- [1, 2, 3]	
- [4, 5, 6]	
- [1, 2, 3, 4, 5, 6]	
- invalid code	
A: [4, 5, 6]	

Q: What would be the value of the variable list2 after the execution of the following code?
list1 = [1, 2, 3]
list2 = []
for element in list1
list2.append(element)
list1 = [4, 5, 6]
- [1, 2, 3]	
- [4, 5, 6]	
- [1, 2, 3, 4, 5, 6]	
- invalid code	
A: [1, 2, 3]	

Q: When working with multiple sets of data, one would typically use a(n) _____.
- list	
- tuple	
- nested list	
- Sequence	
A: nested list	

Q: The primary difference between a tuple and list is that _____.
- when creating a tuple you don’t use commas to separate elements	
- a tuple can only include string elements	
- a tuple cannot include lists as elements	
- once a tuple is created, it cannot be changed	
A: once a tuple is created, it cannot be changed	

Q: What is the advantage of using tuples over lists?
- Tuples are not limited in size.	
- Tuples can include any data type as an element.	
- Processing a tuple is faster than processing a list.	
- There is no advantage.	
A: Processing a tuple is faster than processing a list.	

Q: What method can be used to convert a list to a tuple?
- append	
- tuple	
- insert	
- list	
A: tuple	

Q: What method can be used to convert a tuple to a list?
- append	
- tuple	
- insert	
- list	
A: list	

Q: Invalid indexes do not cause slicing expressions to raise an exception.
- True
- False
A: True

Q: Lists are dynamic data structures such that items may be added to them or removed from them.
- True
- False
A: True

Q: Arrays, which most other programming languages allow, have much more capabilities than list structures.
- True
- False
A: False

Q: A list cannot be passed as an argument to a function.
- True
- False
A: False

Q: The remove method removes all occurrences of the item from a list.
- True
- False
A: False

Q: The sort method rearranges the elements of a list so they appear in ascending or descending order.
- True
- False
A: False

Q: The first step in calculating the average of the values in a list is to get the total of the values.
- True
- False
A: True

Q: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.
- True
- False
A: False

Q: The index – 1 identifies the last element in a list.
- True
- False
A: True

Q: In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.
- True
- False
A: True

Q: A(n) _______________ is an object that holds multiple items of data.
A: sequence

Q: Each element in a tuple has a(n) _______________ that specifies its position in the tuple.
A: index

Q: The built-in function _______________ returns the length of a sequence.
A: len

Q: Tuples are _______________ sequences, which means that once a tuple is created, it cannot be changed.
A: immutable

Q: A(n) _______________ is a span of items that are taken from a sequence.
A: slice

Q: Lists are _______________, which means their elements can be changed.
A: mutable

Q: The _______________ method is commonly used to add items to a list.
A: append

Q: The _______________ exception is raised when a search item is not in the list being searched.
A: ValueError

Q: The _______________ method reverses the order of the items in the list.
A: reverse

Q: The _______________ function returns the item that has the lowest value in the sequence.
A: min

Q: What are the valid indexes for the string ‘New York’?
- 0 through 7
- 0 through 8
- -1 through -8
- -1 through 6
A: 0 through 7

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[ :4]
- ‘7’
- ‘1357’
- ‘1357 ‘
- Invalid code
A: ‘1357’

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[4: ]
- ‘1357’
- ‘Country Ln.’
- ‘ Country Ln.‘
- Invalid code
A: ‘ Country Ln.‘

Q: What will be assigned to the string variable even after the execution of the following code?
special = ‘0123456789’
even = special[0:10:2]
- ‘13579’
- ‘2468’
- ‘02468’
- Invalid code
A: ‘02468’

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[-3: ]
- ‘531’
- ‘Ln.’
- ‘ Ln.’
- ‘7531’
A: ‘Ln.’

Q: If the start index is _____ the end index, the slicing expression will return an empty string.
- equal to
- less than
- greater than
- not equal to
A: greater than

Q: Which of the following string methods can be used to determine if a string contains only ‘\n’ characters?
- ischar()	
- isalpha()	
- istab()	
- isspace()
A: isspace()

Q: What is the return value of the string method lstrip()?
- The string with all whitespace removed
- The string with all leading spaces removed
- The string with all leading tabs removed
- The string with all leading whitespaces removed
A: The string with all leading whitespaces removed

Q: What will be assigned to the string variable pattern after the execution of the following code?
i = 3
pattern = ‘z’ * (5*i)
- ‘zzzzzzzzzzzzzzz’
- ‘zzzzz’
- Error: ‘*’ operator used incorrectly
- The right side of the ‘*’ must be an integer.
A: ‘zzzzzzzzzzzzzzz’

Q: Which list will be referenced by the variable list_strip after the execution of the following code?
list_string = ’03/07/2008’
list_strip = list_string.split(‘/’)
- [‘3’, ‘7’, ‘2008’]
- [‘03’, ‘07’, ‘2008’]
- [‘3’, ‘/’, ‘7’, ‘/’, ‘2008’]
- [‘03’, ‘/’, ‘07’, ‘/’, ‘2008’]
A: [‘03’, ‘07’, ‘2008’]

Q: What is the first negative index in a string?
- 0	
- -1	
- -0	
- Size of the string minus one	
A: -1	

Q: Which method would you use to determine whether a substring is present in a string?
- endswith(substring)	
- find(substring)	
- replace(string, substring)	
- startswith(substring)	
A: find(substring)	

Q: Which method would you use to determine whether a substring is the suffix of a string?
- endswith(substring)	
- find(substring)	
- replace(string, substring)	
- startswith(substring)	
A: endswith(substring)	

Q: What is the value of the variable string after the execution of the following code?
string = 'abcd'
string.upper()
- 'abcd'	
- 'Abcd'	
- 'ABCD'	
- Invalid code	
A: 'ABCD'	

Q: What is the value of the variable string after the execution of the following code?
string = 'Hello'
string += ' world'
- 'Hello'	
- ' world'	
- 'Hello world'	
- Invalid code	
A: 'Hello world'	

Q: Invalid indexes do not cause slicing expressions to raise an exception.
- True
- False
A: True

Q: Indexing works with both strings and lists.
- True
- False
A: True

Q: Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth.
- True
- False
A: False

Q: The index – 1 identifies the last character in a string.
- True
- False
A: True

Q: In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.
- True
- False
A: True

Q: An expression of the form string[i] = 'i' is a valid expression.
- True
- False
A: False

Q: If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands.
- True
- False
A: True

Q: When accessing each character in a string, such as for copying purposes, you would typically use a while loop.
- True
- False
A: False

Q: If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.
- True
- False
A: True

Q: The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters.
- True
- False
A: False

Q: Each character in a string has a(n) _______________ which specifies its position in the string.
A: index

Q: A(n) _______________ exception will occur if you try to use an index that is out of range for a particular string.
A: IndexError

Q: Strings are _______________, which means that once a string is created, it cannot be changed.
A: immutable

Q: A(n) _______________ is a span of characters that are taken from within a string.
A: slice

Q: The _______________ operator can be used to determine whether one string is contained in another string.
A: in

Q: The _______________ method returns true if the string contains only numeric digits.
A: isdigit()

Q: When the operand on the left side of the * symbol is a string and the operand on the right side is an integer, it becomes the _______________ operator.
A: repetition

Q: The _______________ method returns the list of the words in the string.
A: split()

Q: The _______________ method returns a copy of the string with all alphabetic letters converted to lower case.
A: lower()

Q: The third number in string slicing brackets represents the _______________ value.
A: step

Q: In a dictionary, you use a(n) _____ to locate a specific value.
- datum
- element
- item
- key
A: key

Q: What is the correct structure for creating a dictionary of month names to be accessed by month numbers?
- { 1 ; 'January', 2 ; 'February', 3 ; 'March' }
- { 1 : 'January', 2 : 'February', 3 : 'March' }
- [ 1 : 'January', 2 : 'February', 3 : 'March' ]
- { 1, 2, 3 : 'January', 'February', 'March' }
A: { 1 : 'January', 2 : 'February', 3 : 'March' }

Q: What would be the result of the following code?
ages = {'Aaron' : 6, 'Kelly' : 3, 'Abigail' : 1 }
value = ages['Brianna']
- false
- -1
- 0
- KeyError
A: KeyError

Q: What is the number of the first index in a list dictionary?
- 0	
- 1	
- Dictionary is not indexed by number.	
- Size of the dictionary minus one.	
A: Dictionary is not indexed by number.	

Q: You created the following dictionary relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception?
relationships['jimmy']
- String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.	
- You used the wrong syntax for creating the dictionary.	
- You should have used the code relationships['brother'].	
- There is a bug in Python.	
A: String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.	

Q: In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the _____ operator.
- included	
- of	
- in	
- not in	
A: in	

Q: What is the value of the variable phones after the execution of the following code?
phones = {'John': '5555555', 'Julie' : '7777777'}
phones['John'] = '1234567'
- {'John': '5555555', 'Julie' : '7777777'}	
- {'John': '1234567', 'Julie' : '7777777'}	
- {'John': '1234567' }	
- invalid code
A: {'John': '1234567', 'Julie' : '7777777'}	

Q: Which statement would you use to delete an existing key-value pair from a dictionary?
- del	
- remove	
- delete	
- unpair	
A: del	

Q: Which function would you use to get the number of elements in a dictionary?
- size	
- length	
- len	
- invalid code	
A: len	

Q: Which method would you use to returns all the elements in the dictionary as a list of tuples?
- list	
- items	
- pop	
- keys	
A: items	

Q: Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?
- list	
- items	
- popitem	
- pop	
A: pop	

Q: What does the get method do if the specified key is not found in the dictionary?
- Throw an exception	
- Nothing	
- Return a default value	
- You do not specify a key for the get method	
A: Return a default value	

Q: Which of the following does not apply to sets?
- The stored elements can be of different data types.	
- All the elements must be unique – no two elements can have the same value.	
- The elements are unordered.	
- The elements are pairs.	
A: The elements are pairs.	

Q: What method can be used to add a group of elements to a set?
- add	
- addgroup	
- update	
- Elements must be added one at a time.	
A: update	

Q: What is the process used to convert an object to a stream of bytes that can be saved in a file?
- Pickling	
- Streaming	
- Writing	
- Dumping	
A: Pickling	

Q: You would typically use a for loop to iterate over the elements in a set.
- True
- False
A: True

Q: Sets are immutable.
- True
- False
A: False

Q: Sets are created using curly braces {}.
- True
- False
A: False

Q: The set remove and discard methods behave differently only when a specified item is not found in the set.
- True
- False
A: True

Q: A dictionary can include the same value several times, but cannot include the same key several times.
- True
- False
A: True

Q: The union of two sets is a set that contains only the elements that appear in both sets.
- True
- False
A: False

Q: The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.
- True
- False
A: True

Q: The index of the first element in a set is 0.
- True
- False
A: False

Q: The index of the first key-value pair in a dictionary is 0.
- True
- False
A: False

Q: The issubset method can be used to determine whether set1 is a subset of set2.
- True
- False
A: True

Q: A(n) _______________ is an object that holds multiple unique items of data in an unordered manner.
A: set

Q: The _______________ of two sets is a set that contains all the elements of both sets.
A: union

Q: The built-in function _______________ returns the number of items in a set.
A: len

Q: To add a single item to a set, you can use the set method _______________.
A: add

Q: Each element in a(n) _______________ has two parts: a key and a value.
A: dictionary

Q: The elements in a dictionary are not stored in a specific order. Therefore a dictionary is not a(n) _______________.
A: sequence

Q: To determine whether a key is not included in a dictionary, or an element is not included in a set, you can use the _______________ operator.
A: not in

Q: The _______________ method returns a value associated with a specified key and if found, removes that key-value pair from the dictionary.
A: pop

Q: The _______________ method clears the contents of a dictionary.
A: clear

Q: To write an object to a file, you use the _______________ function of the _______________ module.
A: dump, pickle

Q: A(n) _____ is a set of real-world objects, parties, and major events related to the problem.
- class
- problem domain
- object
- instance
A: problem domain

Q: What does the acronym UML stand for?
- Unified Modeling Language
- United Modeling Language
- Unified Model Language
- United Model Language
A: Unified Modeling Language

Q: Which section in the UML holds the list of the class’s data attributes?
- First
- Second
- Third
- Fourth
A: Second

Q: The list of the class’s methods is in which section in the UML?
- First
- Second
- Third
- Fourth
A: Third

Q: What type of method provides a safe way for code outside a class to retrieve the values of attributes, without exposing the attributes in a way that they could be changed by the code outside the method?
- Accessor
- Mutator
- Setter
- Class
A: Accessor

Q: What attributes belong to a specific instance of the class?
- Instance
- Self
- Object
- Data
A: Instance

Q: What is the special name given to the method that returns a string containing the object’s state?
- __state__	
- __obj__	
- __str__	
- __init__
A: __str__	

Q: Which method is automatically executed when an instance of the class is created in memory?
- __state__	
- __obj__	
- __str__	
- __init__
A: __init__

Q: When a method is called, what does Python make to reference the specific object on which the method is supposed to operate?
- state variable
- self parameter
- object data
- init procedure
A: self parameter

Q: What type of programming contains class definitions?
- Procedural
- Object
- Object-oriented
- Modular
A: Object-oriented

Q: What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?
- Class
- Object
- Instance
- Module
A: Object

Q: What are the procedures that an object performs called?
- Methods
- Actions
- Modules
- Instances
A: Methods

Q: What is the combining of data and code in a single object known as?
- Modularity
- Instantiation
- Encapsulation
- Objectification
A: Encapsulation

Q: What is another name for the mutator methods?
- Setters	
- Getters	
- Instances	
- Attributes	
A: Setters	

Q: Another name for the accessor methods is ______________?
- Setters	
- Getters	
- Instances	
- Attributes	
A: Getters	

Q: A mutator method has no control over the way that a class’s data attributes are modified.
- True
- False
A: False

Q: In a UML diagram, the middle section holds the list of the class’s methods.
- True
- False
A: False

Q: Procedures operate on data items that are separate from the procedures.
- True
- False
A: True

Q: Object-oriented programming allows us to hide the object’s data attributes from code that is outside the object.
- True
- False
A: True

Q: The instances of a class share the data attributes in the class.
- True
- False
A: False

Q: A class definition is stored in the library so that it can be imported into any program.
- True
- False
A: False

Q: The self parameter need not be named self, but it is strongly recommended to conform with standard practice.
- True
- False
A: True

Q: The self parameter is required in every method of a class.
- True
- False
A: True

Q: A class might be thought of as a ‘blueprint’ that an object may be created from.
- True
- False
A: True

Q: An object is a stand-alone program but is used by programs that need its service.
- True
- False
A: False

Q: A(n) _____________ is code that specifies the data attributes and methods for a particular type of object.
A: class

Q: Each object that is created from a class is called a(n) _______________ of the class.
A: instance

Q: A class _______________ is a set of statements that define a class’s methods and data attributes.
A: definition

Q: A(n) ___________ method in a class initializes an object’s data attributes.
A: initializer

Q: An object’s _______________ is simply the values of the object’s attributes at any given moment.
A: state

Q: The _______________ attributes are created by the self parameter and they belong to a specific instance of the class.
A: instance

Q: A method that returns a value from a class’s attribute but does not change it is known as a(n) _______________ method.
A: accessor

Q: _______________ provides a set of standard diagrams for graphically depicting object-oriented systems.
A: UML

Q: In _______________ programming, the programming is centered on objects that are created from abstract data types that encapsulate data and functions together.
A: object-oriented

Q: _______________ programming is a method of writing software that centers on the actions that take place in a program.
A: Procedural

Q: _____ allows a new class to inherit the members of the class it extends.
- Encapsulation
- Domain
- Methods
- Inheritance
A: Inheritance

Q: What concept involves a superclass and a subclass?
- Polymorphism
- Inheritance
- Encapsulation
- Methods
A: Inheritance

Q: What gives a program the ability to call the correct method depending on the type of object that is used to call it?
- Polymorphism	
- Inheritance	
- Encapsulation	
- Methods	
A: Polymorphism	

Q: What does a subclass inherit from a superclass?
- Instances and attributes
- Data and methods
- Methods and instances
- Attributes and methods
A: Attributes and methods

Q: In the following line of code, what is the name of the subclass?
class Rose(Flower):
- Rose
- Flower
- Either
- Incorrect code

6., What is the name of the base class in the following line of code?
class Male(Human):
a. Male
*b. Human
c. Either
d. Incorrect code
A: Rose

Q: In a UML diagram, what does the open arrowhead point to?
- Superclass	
- Subclass	
- Object	
- Method
A: Superclass	

Q: Examine the following piece of code:
class Potato (Vegetable):
In a UML diagram, what would the open arrowhead point to?
- Potato	
- Vegetable	
- class	
- Potato(Vegetable)
A: Vegetable	

Q: When there are several classes that have many common data attributes, it is better to write a(n) _____ to hold all the general data.
- superclass
- subclass
- object
- method
A: superclass

Q: In an inheritance relationship, what is a specialized class called?
- Superclass
- Subclass
- Object
- Method
A: Subclass

Q: Of the two classes Cola and Soda, which would most likely be the subclass?
- Cola
- Soda
- Both
- Either
A: Cola

Q: Which method can you use to determine whether an object is an instance of a class?
- isinstance
- isclass
- isobject
- isinheritance
A: isinstance

Q: Which of the following is the correct syntax for defining a class dining which inherits from class furniture?
- class furniture(dining)
- class dining(furniture)
- class furniture(dining):
- class dining(furniture):
A: class dining(furniture):

Q: Base classes are also called _____.
- superclasses	
- derived	
- subclasses	
- classes	
A: superclasses	

Q: What is the relationship called in which one object is a specialized version of another object?
- Parent-child	
- Node	
- Is a	
- Class	
A: Is a	

Q: New attributes and methods may be added to a subclass.
- True
- False
A: True

Q: It is not possible to indicate inheritance in a UML diagram.
- True
- False
A: False

Q: Each subclass has a method named __init__ that overrides the superclass’s __init__.
- True
- False
A: True

Q: When a class inherits another class, it is required to use all the data attributes and methods of the superclass.
- True
- False
A: False

Q: An ‘is a’ relationship exists between a grasshopper and a bumblebee.
- True
- False
A: False

Q: In a UML diagram depicting inheritance, you only write the name of the subclass.
- True
- False
A: False

Q: A subclass may not override any method other than the __init__ method.
- True
- False
A: False

Q: Polymorphism works on any two class methods that have the same name.
- True
- False
A: True

Q: One of the ingredients of polymorphic behavior is the ability to define a method in a subclass, and then define a method with the same name in a superclass.
- True
- False
A: False

Q: A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
- True
- False
A: False

Q: _______________ allows subclasses to have methods with the same names as methods in their superclasses.
A: Polymorphism

Q: The _______________ function determines whether an object is an instance of a specific class, or an instance of a subclass of that class.
A: isinstance

Q: A subclass is also called a(n) _______________ class.
A: derived

Q: _______________ is used to create an ‘is a’ relationship among classes.
A: Inheritance

Q: When a subclass method has the same name as a superclass method, it is often said that the subclass method _______________ the superclass method.
A: overrides

Q: In an inheritance relationship, the extended class is called the _______________.
A: subclass

Q: Superclasses are also called _______________ classes.
A: base

Q: New attributes and methods may be added to a subclass, which makes it a(n) _______________ version of the superclass.
A: specialized

Q: In an inheritance relationship, a television is a(n) _______________ of the electronics class.
A: subclass

Q: The term _______________ refers to an object’s ability to take different forms.
A: polymorphism

Q: If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____.
- exits
- returns to the main function
- returns to the calling function
- calls itself to solve the smaller problem
A: calls itself to solve the smaller problem

Q: What is the first step that needs to be taken in order to apply a recursive approach?
- Identify at least one case in which the problem can be solved without recursion.
- Determine a way to solve the problem in all other circumstances using recursion.
- Identify a way to stop the recursion.
- Determine a way to return to the main function.
A: Identify at least one case in which the problem can be solved without recursion.

Q: What is the second step that needs to be taken in order to apply a recursive approach?
- Identify at least one case in which the problem can be solved without recursion.		
- Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.		
- Identify a way to stop the recursion.		
- Determine a way to return to the main function.		
A: Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.		

Q: Function A calls function B, which calls function C, which calls function A. This is called _____ recursion.
- continuous
- direct
- three function call
- indirect
A: indirect

Q: A problem can be solved with recursion if it can be broken down into _____ problems.
- smaller
- one-line
- manageable
- modular
A: smaller

Q: The base case is a case in which the problem can be solved without _____.
- loops
- if
- objects
- recursion
A: recursion

Q: What is referred to as the recursive case?
- At least one case in which the problem can be solved without recursion		
- A way to solve the problem in all other circumstances using recursion		
- The way to stop the recursion		
- The way to return to the main function
A: A way to solve the problem in all other circumstances using recursion		

Q: What is referred to as the base case?
- At least one case in which the problem can be solved without recursion		
- The circumstances to solve the problem using recursion		
- The way to stop the recursion		
- The way to return to the main function
A: At least one case in which the problem can be solved without recursion		

Q: If the problem can be solved immediately without recursion, then the recursive function _____.
- solves it and returns
- Exits
- returns the result
- generates a run-time error
A: solves it and returns

Q: The process of calling a function requires _____.
- a long memory access
- a quick memory access
- several actions to be performed by the computer
- one action to be performed by the computer
A: several actions to be performed by the computer

Q: Recursion is _____.
- never required to solve a problem
- required to solve mathematical problems
- never required to solve string problems
- required to solve some problems
A: never required to solve a problem

Q: A function is called from the main function for the first time. It then calls itself seven times. What is the depth of recursion?
- Eight
- Two
- One
- Seven
A: Seven

Q: What defines the depth of recursion?
- The length of the algorithm
- The numbers of function calls
- The number of times the function calls itself
- The number of times it goes back to the main function
A: The number of times the function calls itself

Q: Recursive functions are _____ iterative algorithms.
- more efficient than	
- less efficient than 	
- as efficient as	
- incomparable to	
A: less efficient than 	

Q: A recursive function includes _____ which are not necessary in a loop structure.
- function calls	
- conditional clauses	
- overhead actions	
- object instances	
A: overhead actions	

Q: A recursive function must have some way to control the number of times it repeats.
- True
- False
A: True

Q: In many cases a solution using recursion is more evident than a solution using a loop.
- True
- False
A: False

Q: If a recursive solution is evident for a particular problem, and the recursive algorithm does not slow system performance by an intolerable amount, then recursion would be a good design choice.
- True
- False
A: True

Q: A base case is not necessary for all recursive algorithms.
- True
- False
A: False

Q: There can be several functions involved in the recursion.
- True
- False
A: True

Q: Each time a function is called, the system incurs overhead that is not necessary with a loop.
- True
- False
A: True

Q: When function A calls function B, which in turn calls function A, it is known as indirect recursion.
- True
- False
A: True

Q: Recursion can be used to solve a problem that can be broken into smaller problems that are identical in structure to the overall problem.
- True
- False
A: True

Q: Recursive algorithms are more concise and efficient than iterative algorithms.
- True
- False
A: False

Q: Recursion is required to solve some type of problems.
- True
- False
A: False

Q: All the cases of the recursive solution other than the base case are called the _______________ case.
A: recursive

Q: The base case does not require _______________, so it stops the chain of recursive calls.
A: recursion

Q: Recursive function calls are _______________ efficient than loops.
A: less

Q: Each time a function is called, the system incurs _______________ that is not necessary with a loop.
A: overhead

Q: A solution using a(n) _______________ is usually more evident than a recursive solution.
A: loop

Q: A function is called from the main function and then it calls itself five times. The depth of recursion is _______________.
A: five

Q: The majority of repetitive programming tasks are best done with _______________.
A: loops

Q: A recursion in which a function directly calls itself is known as _______________ recursion.
A: direct

Q: Usually, a problem is reduced by making the value of one or more parameters _______________ with each recursive call.
A: smaller

Q: Some problems are _______________ solved with recursion than with a loop.
A: more easily

Q: What are the items that appear on the graphical interface window called?
- Buttons
- Icons
- Widgets
- Graphical elements
A: Widgets

Q: What types of programs are event-driven?
- GUI programs
- Command line programs
- Procedural programs
- Modular programs
A: GUI programs

Q: Which widget allows the user to select a value by moving a slider along a track?
- Entry	
- Scale	
- Scrollbar	
- Slider	
A: Scale	

Q: The Toplevel widget is a container, like a(n) _____, but displays in its own window.
- Label
- Frame
- Canvas
- Message
A: Frame

Q: Which widget will display multiple lines of text?
- Label
- Canvas
- Message
- Text
A: Message

Q: Which widget will create an area that displays one line of text or an image?
- Label
- Frame
- Canvas
- Message
A: Label

Q: Which widget will create a rectangular area that can be used to display graphics?
- Label	
- Frame	
- Canvas	
- Message
A: Canvas	

Q: In Python, what module is used to create a GUI program?
- tkinter	
- Pgui	
- gint	
- pygui
A: tkinter	

Q: In which environment can a user determine the order in which things happen?
- Command line
- GUI
- ALU
- CPU
A: GUI

Q: In a GUI environment, most interactions are done through small windows known as _____ that display information and allow the user to perform actions.
- input boxes
- windows
- dialog boxes
- message boxes
A: dialog boxes

Q: In which type of interface is a prompt displayed that allows the user to enter a command, which is then executed?
- Command line
- GUI
- ALU
- CPU
A: Command line

Q: The _____ accepts the user’s commands.
- register
- CPU
- operating system
- ALU
A: operating system

Q: With what part of the computer does the user interact?
- Graphical unit
- User interface
- Register
- CPU
A: User interface

Q: How many graphical widgets does the tkinter module provide?
- Five	
- Ten	
- Fifteen	
- Twenty	
A: Fifteen	

Q: The acronym GUI stands for:
- Graphical User Interface	
- Graphical Unit Interface	
- Graphical User Interaction	
- Graphical Users’ Interface	
A: Graphical User Interface	

Q: Python does not have GUI programming features built into the language itself.
- True
- False
A: True

Q: Programs that use tkinter do not always run reliably under IDLE.
- True
- False
A: True

Q: A root widget's destroy method can be used as a callback function for a quit button.
- True
- False
A: True

Q: Using the radio buttons, the user can make multiple selections at one time.
- True
- False
A: False

Q: Check buttons are displayed in groups and used to make mutually exclusive selections.
- True
- False
A: False

Q: Many computer users find a command line interface relatively easy to use.
- True
- False
A: False

Q: In a GUI environment, no text input is possible.
- True
- False
A: False

Q: The pack method determines where a widget should be positioned.
- True
- False
A: True

Q: An info dialog box is a simple window that displays a message to the user and has an OK button that closes the dialog box.
- True
- False
A: True

Q: To use the showinfo function, the tkinter.messagebox module needs to be imported.
- True
- False
A: True

Q: A(n) _______________ allows the user to interact with the operating system and other programs through graphical elements on the screen.
A: GUI

Q: The GUI popularized the use of the _______________ as an input device.
A: mouse

Q: _______________ are small windows that display information and allow the user to perform actions.
A: Dialog boxes

Q: GUI programs respond to the actions of the user, and so they are called _______________ programs.
A: event-driven

Q: The _______________ module allows you to create GUI programs in Python.
A: tkinter

Q: The _______________ widget is used to display text in a window.
A: Label

Q: The Label widget’s _______________ method determines where a widget should be positioned and makes the widget visible when the main window is displayed.
A: pack

Q: A(n) _______________ is a container that can hold other widgets and organize the widgets in a window.
A: Frame

Q: A(n) _______________ function is a function or method that executes when the user clicks the button.
A: callback

Q: A(n) _______________ is a widget that the user can click to cause an action to occur.
A: Button

Q: What are the items that appear on the graphical interface window called?
- Buttons
- Icons
- Widgets
- Graphical elements
A: Widgets

Q: What types of programs are event-driven?
- GUI programs
- Command line programs
- Procedural programs
- Modular programs
A: GUI programs

Q: Which widget allows the user to select a value by moving a slider along a track?
- Entry	
- Scale	
- Scrollbar	
- Slider	
A: Scale	

Q: The Toplevel widget is a container, like a(n) _____, but displays in its own window.
- Label
- Frame
- Canvas
- Message
A: Frame

Q: Which widget will display multiple lines of text?
- Label
- Canvas
- Message
- Text
A: Message

Q: Which widget will create an area that displays one line of text or an image?
- Label
- Frame
- Canvas
- Message
A: Label

Q: Which widget will create a rectangular area that can be used to display graphics?
- Label	
- Frame	
- Canvas	
- Message
A: Canvas	

Q: In Python, what module is used to create a GUI program?
- tkinter	
- Pgui	
- gint	
- pygui
A: tkinter	

Q: In which environment can a user determine the order in which things happen?
- Command line
- GUI
- ALU
- CPU
A: GUI

Q: In a GUI environment, most interactions are done through small windows known as _____ that display information and allow the user to perform actions.
- input boxes
- windows
- dialog boxes
- message boxes
A: dialog boxes

Q: In which type of interface is a prompt displayed that allows the user to enter a command, which is then executed?
- Command line
- GUI
- ALU
- CPU
A: Command line

Q: The _____ accepts the user’s commands.
- register
- CPU
- operating system
- ALU
A: operating system

Q: With what part of the computer does the user interact?
- Graphical unit
- User interface
- Register
- CPU
A: User interface

Q: How many graphical widgets does the tkinter module provide?
- Five	
- Ten	
- Fifteen	
- Twenty	
A: Fifteen	

Q: The acronym GUI stands for:
- Graphical User Interface	
- Graphical Unit Interface	
- Graphical User Interaction	
- Graphical Users’ Interface	
A: Graphical User Interface	

Q: Python does not have GUI programming features built into the language itself.
- True
- False
A: True

Q: Programs that use tkinter do not always run reliably under IDLE.
- True
- False
A: True

Q: A root widget's destroy method can be used as a callback function for a quit button.
- True
- False
A: True

Q: Using the radio buttons, the user can make multiple selections at one time.
- True
- False
A: False

Q: Check buttons are displayed in groups and used to make mutually exclusive selections.
- True
- False
A: False

Q: Many computer users find a command line interface relatively easy to use.
- True
- False
A: False

Q: In a GUI environment, no text input is possible.
- True
- False
A: False

Q: The pack method determines where a widget should be positioned.
- True
- False
A: True

Q: An info dialog box is a simple window that displays a message to the user and has an OK button that closes the dialog box.
- True
- False
A: True

Q: To use the showinfo function, the tkinter.messagebox module needs to be imported.
- True
- False
A: True

Q: A(n) _______________ allows the user to interact with the operating system and other programs through graphical elements on the screen.
A: GUI

Q: The GUI popularized the use of the _______________ as an input device.
A: mouse

Q: _______________ are small windows that display information and allow the user to perform actions.
A: Dialog boxes

Q: GUI programs respond to the actions of the user, and so they are called _______________ programs.
A: event-driven

Q: The _______________ module allows you to create GUI programs in Python.
A: tkinter

Q: The _______________ widget is used to display text in a window.
A: Label

Q: The Label widget’s _______________ method determines where a widget should be positioned and makes the widget visible when the main window is displayed.
A: pack

Q: A(n) _______________ is a container that can hold other widgets and organize the widgets in a window.
A: Frame

Q: A(n) _______________ function is a function or method that executes when the user clicks the button.
A: callback

Q: A(n) _______________ is a widget that the user can click to cause an action to occur.
A: Button

Q: If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____.
- exits
- returns to the main function
- returns to the calling function
- calls itself to solve the smaller problem
A: calls itself to solve the smaller problem

Q: What is the first step that needs to be taken in order to apply a recursive approach?
- Identify at least one case in which the problem can be solved without recursion.
- Determine a way to solve the problem in all other circumstances using recursion.
- Identify a way to stop the recursion.
- Determine a way to return to the main function.
A: Identify at least one case in which the problem can be solved without recursion.

Q: What is the second step that needs to be taken in order to apply a recursive approach?
- Identify at least one case in which the problem can be solved without recursion.		
- Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.		
- Identify a way to stop the recursion.		
- Determine a way to return to the main function.		
A: Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.		

Q: Function A calls function B, which calls function C, which calls function A. This is called _____ recursion.
- continuous
- direct
- three function call
- indirect
A: indirect

Q: A problem can be solved with recursion if it can be broken down into _____ problems.
- smaller
- one-line
- manageable
- modular
A: smaller

Q: The base case is a case in which the problem can be solved without _____.
- loops
- if
- objects
- recursion
A: recursion

Q: What is referred to as the recursive case?
- At least one case in which the problem can be solved without recursion		
- A way to solve the problem in all other circumstances using recursion		
- The way to stop the recursion		
- The way to return to the main function
A: A way to solve the problem in all other circumstances using recursion		

Q: What is referred to as the base case?
- At least one case in which the problem can be solved without recursion		
- The circumstances to solve the problem using recursion		
- The way to stop the recursion		
- The way to return to the main function
A: At least one case in which the problem can be solved without recursion		

Q: If the problem can be solved immediately without recursion, then the recursive function _____.
- solves it and returns
- Exits
- returns the result
- generates a run-time error
A: solves it and returns

Q: The process of calling a function requires _____.
- a long memory access
- a quick memory access
- several actions to be performed by the computer
- one action to be performed by the computer
A: several actions to be performed by the computer

Q: Recursion is _____.
- never required to solve a problem
- required to solve mathematical problems
- never required to solve string problems
- required to solve some problems
A: never required to solve a problem

Q: A function is called from the main function for the first time. It then calls itself seven times. What is the depth of recursion?
- Eight
- Two
- One
- Seven
A: Seven

Q: What defines the depth of recursion?
- The length of the algorithm
- The numbers of function calls
- The number of times the function calls itself
- The number of times it goes back to the main function
A: The number of times the function calls itself

Q: Recursive functions are _____ iterative algorithms.
- more efficient than	
- less efficient than 	
- as efficient as	
- incomparable to	
A: less efficient than 	

Q: A recursive function includes _____ which are not necessary in a loop structure.
- function calls	
- conditional clauses	
- overhead actions	
- object instances	
A: overhead actions	

Q: A recursive function must have some way to control the number of times it repeats.
- True
- False
A: True

Q: In many cases a solution using recursion is more evident than a solution using a loop.
- True
- False
A: False

Q: If a recursive solution is evident for a particular problem, and the recursive algorithm does not slow system performance by an intolerable amount, then recursion would be a good design choice.
- True
- False
A: True

Q: A base case is not necessary for all recursive algorithms.
- True
- False
A: False

Q: There can be several functions involved in the recursion.
- True
- False
A: True

Q: Each time a function is called, the system incurs overhead that is not necessary with a loop.
- True
- False
A: True

Q: When function A calls function B, which in turn calls function A, it is known as indirect recursion.
- True
- False
A: True

Q: Recursion can be used to solve a problem that can be broken into smaller problems that are identical in structure to the overall problem.
- True
- False
A: True

Q: Recursive algorithms are more concise and efficient than iterative algorithms.
- True
- False
A: False

Q: Recursion is required to solve some type of problems.
- True
- False
A: False

Q: All the cases of the recursive solution other than the base case are called the _______________ case.
A: recursive

Q: The base case does not require _______________, so it stops the chain of recursive calls.
A: recursion

Q: Recursive function calls are _______________ efficient than loops.
A: less

Q: Each time a function is called, the system incurs _______________ that is not necessary with a loop.
A: overhead

Q: A solution using a(n) _______________ is usually more evident than a recursive solution.
A: loop

Q: A function is called from the main function and then it calls itself five times. The depth of recursion is _______________.
A: five

Q: The majority of repetitive programming tasks are best done with _______________.
A: loops

Q: A recursion in which a function directly calls itself is known as _______________ recursion.
A: direct

Q: Usually, a problem is reduced by making the value of one or more parameters _______________ with each recursive call.
A: smaller

Q: Some problems are _______________ solved with recursion than with a loop.
A: more easily

Q: _____ allows a new class to inherit the members of the class it extends.
- Encapsulation
- Domain
- Methods
- Inheritance
A: Inheritance

Q: What concept involves a superclass and a subclass?
- Polymorphism
- Inheritance
- Encapsulation
- Methods
A: Inheritance

Q: What gives a program the ability to call the correct method depending on the type of object that is used to call it?
- Polymorphism	
- Inheritance	
- Encapsulation	
- Methods	
A: Polymorphism	

Q: What does a subclass inherit from a superclass?
- Instances and attributes
- Data and methods
- Methods and instances
- Attributes and methods
A: Attributes and methods

Q: In the following line of code, what is the name of the subclass?
class Rose(Flower):
- Rose
- Flower
- Either
- Incorrect code

6., What is the name of the base class in the following line of code?
class Male(Human):
a. Male
*b. Human
c. Either
d. Incorrect code
A: Rose

Q: In a UML diagram, what does the open arrowhead point to?
- Superclass	
- Subclass	
- Object	
- Method
A: Superclass	

Q: Examine the following piece of code:
class Potato (Vegetable):
In a UML diagram, what would the open arrowhead point to?
- Potato	
- Vegetable	
- class	
- Potato(Vegetable)
A: Vegetable	

Q: When there are several classes that have many common data attributes, it is better to write a(n) _____ to hold all the general data.
- superclass
- subclass
- object
- method
A: superclass

Q: In an inheritance relationship, what is a specialized class called?
- Superclass
- Subclass
- Object
- Method
A: Subclass

Q: Of the two classes Cola and Soda, which would most likely be the subclass?
- Cola
- Soda
- Both
- Either
A: Cola

Q: Which method can you use to determine whether an object is an instance of a class?
- isinstance
- isclass
- isobject
- isinheritance
A: isinstance

Q: Which of the following is the correct syntax for defining a class dining which inherits from class furniture?
- class furniture(dining)
- class dining(furniture)
- class furniture(dining):
- class dining(furniture):
A: class dining(furniture):

Q: Base classes are also called _____.
- superclasses	
- derived	
- subclasses	
- classes	
A: superclasses	

Q: What is the relationship called in which one object is a specialized version of another object?
- Parent-child	
- Node	
- Is a	
- Class	
A: Is a	

Q: New attributes and methods may be added to a subclass.
- True
- False
A: True

Q: It is not possible to indicate inheritance in a UML diagram.
- True
- False
A: False

Q: Each subclass has a method named __init__ that overrides the superclass’s __init__.
- True
- False
A: True

Q: When a class inherits another class, it is required to use all the data attributes and methods of the superclass.
- True
- False
A: False

Q: An ‘is a’ relationship exists between a grasshopper and a bumblebee.
- True
- False
A: False

Q: In a UML diagram depicting inheritance, you only write the name of the subclass.
- True
- False
A: False

Q: A subclass may not override any method other than the __init__ method.
- True
- False
A: False

Q: Polymorphism works on any two class methods that have the same name.
- True
- False
A: True

Q: One of the ingredients of polymorphic behavior is the ability to define a method in a subclass, and then define a method with the same name in a superclass.
- True
- False
A: False

Q: A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
- True
- False
A: False

Q: _______________ allows subclasses to have methods with the same names as methods in their superclasses.
A: Polymorphism

Q: The _______________ function determines whether an object is an instance of a specific class, or an instance of a subclass of that class.
A: isinstance

Q: A subclass is also called a(n) _______________ class.
A: derived

Q: _______________ is used to create an ‘is a’ relationship among classes.
A: Inheritance

Q: When a subclass method has the same name as a superclass method, it is often said that the subclass method _______________ the superclass method.
A: overrides

Q: In an inheritance relationship, the extended class is called the _______________.
A: subclass

Q: Superclasses are also called _______________ classes.
A: base

Q: New attributes and methods may be added to a subclass, which makes it a(n) _______________ version of the superclass.
A: specialized

Q: In an inheritance relationship, a television is a(n) _______________ of the electronics class.
A: subclass

Q: The term _______________ refers to an object’s ability to take different forms.
A: polymorphism

Q: A(n) _____ is a set of real-world objects, parties, and major events related to the problem.
- class
- problem domain
- object
- instance
A: problem domain

Q: What does the acronym UML stand for?
- Unified Modeling Language
- United Modeling Language
- Unified Model Language
- United Model Language
A: Unified Modeling Language

Q: Which section in the UML holds the list of the class’s data attributes?
- First
- Second
- Third
- Fourth
A: Second

Q: The list of the class’s methods is in which section in the UML?
- First
- Second
- Third
- Fourth
A: Third

Q: What type of method provides a safe way for code outside a class to retrieve the values of attributes, without exposing the attributes in a way that they could be changed by the code outside the method?
- Accessor
- Mutator
- Setter
- Class
A: Accessor

Q: What attributes belong to a specific instance of the class?
- Instance
- Self
- Object
- Data
A: Instance

Q: What is the special name given to the method that returns a string containing the object’s state?
- __state__	
- __obj__	
- __str__	
- __init__
A: __str__	

Q: Which method is automatically executed when an instance of the class is created in memory?
- __state__	
- __obj__	
- __str__	
- __init__
A: __init__

Q: When a method is called, what does Python make to reference the specific object on which the method is supposed to operate?
- state variable
- self parameter
- object data
- init procedure
A: self parameter

Q: What type of programming contains class definitions?
- Procedural
- Object
- Object-oriented
- Modular
A: Object-oriented

Q: What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?
- Class
- Object
- Instance
- Module
A: Object

Q: What are the procedures that an object performs called?
- Methods
- Actions
- Modules
- Instances
A: Methods

Q: What is the combining of data and code in a single object known as?
- Modularity
- Instantiation
- Encapsulation
- Objectification
A: Encapsulation

Q: What is another name for the mutator methods?
- Setters	
- Getters	
- Instances	
- Attributes	
A: Setters	

Q: Another name for the accessor methods is ______________?
- Setters	
- Getters	
- Instances	
- Attributes	
A: Getters	

Q: A mutator method has no control over the way that a class’s data attributes are modified.
- True
- False
A: False

Q: In a UML diagram, the middle section holds the list of the class’s methods.
- True
- False
A: False

Q: Procedures operate on data items that are separate from the procedures.
- True
- False
A: True

Q: Object-oriented programming allows us to hide the object’s data attributes from code that is outside the object.
- True
- False
A: True

Q: The instances of a class share the data attributes in the class.
- True
- False
A: False

Q: A class definition is stored in the library so that it can be imported into any program.
- True
- False
A: False

Q: The self parameter need not be named self, but it is strongly recommended to conform with standard practice.
- True
- False
A: True

Q: The self parameter is required in every method of a class.
- True
- False
A: True

Q: A class might be thought of as a ‘blueprint’ that an object may be created from.
- True
- False
A: True

Q: An object is a stand-alone program but is used by programs that need its service.
- True
- False
A: False

Q: A(n) _____________ is code that specifies the data attributes and methods for a particular type of object.
A: class

Q: Each object that is created from a class is called a(n) _______________ of the class.
A: instance

Q: A class _______________ is a set of statements that define a class’s methods and data attributes.
A: definition

Q: A(n) ___________ method in a class initializes an object’s data attributes.
A: initializer

Q: An object’s _______________ is simply the values of the object’s attributes at any given moment.
A: state

Q: The _______________ attributes are created by the self parameter and they belong to a specific instance of the class.
A: instance

Q: A method that returns a value from a class’s attribute but does not change it is known as a(n) _______________ method.
A: accessor

Q: _______________ provides a set of standard diagrams for graphically depicting object-oriented systems.
A: UML

Q: In _______________ programming, the programming is centered on objects that are created from abstract data types that encapsulate data and functions together.
A: object-oriented

Q: _______________ programming is a method of writing software that centers on the actions that take place in a program.
A: Procedural

Q: In a dictionary, you use a(n) _____ to locate a specific value.
- datum
- element
- item
- key
A: key

Q: What is the correct structure for creating a dictionary of month names to be accessed by month numbers?
- { 1 ; 'January', 2 ; 'February', 3 ; 'March' }
- { 1 : 'January', 2 : 'February', 3 : 'March' }
- [ 1 : 'January', 2 : 'February', 3 : 'March' ]
- { 1, 2, 3 : 'January', 'February', 'March' }
A: { 1 : 'January', 2 : 'February', 3 : 'March' }

Q: What would be the result of the following code?
ages = {'Aaron' : 6, 'Kelly' : 3, 'Abigail' : 1 }
value = ages['Brianna']
- false
- -1
- 0
- KeyError
A: KeyError

Q: What is the number of the first index in a list dictionary?
- 0	
- 1	
- Dictionary is not indexed by number.	
- Size of the dictionary minus one.	
A: Dictionary is not indexed by number.	

Q: You created the following dictionary relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception?
relationships['jimmy']
- String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.	
- You used the wrong syntax for creating the dictionary.	
- You should have used the code relationships['brother'].	
- There is a bug in Python.	
A: String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.	

Q: In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the _____ operator.
- included	
- of	
- in	
- not in	
A: in	

Q: What is the value of the variable phones after the execution of the following code?
phones = {'John': '5555555', 'Julie' : '7777777'}
phones['John'] = '1234567'
- {'John': '5555555', 'Julie' : '7777777'}	
- {'John': '1234567', 'Julie' : '7777777'}	
- {'John': '1234567' }	
- invalid code
A: {'John': '1234567', 'Julie' : '7777777'}	

Q: Which statement would you use to delete an existing key-value pair from a dictionary?
- del	
- remove	
- delete	
- unpair	
A: del	

Q: Which function would you use to get the number of elements in a dictionary?
- size	
- length	
- len	
- invalid code	
A: len	

Q: Which method would you use to returns all the elements in the dictionary as a list of tuples?
- list	
- items	
- pop	
- keys	
A: items	

Q: Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?
- list	
- items	
- popitem	
- pop	
A: pop	

Q: What does the get method do if the specified key is not found in the dictionary?
- Throw an exception	
- Nothing	
- Return a default value	
- You do not specify a key for the get method	
A: Return a default value	

Q: Which of the following does not apply to sets?
- The stored elements can be of different data types.	
- All the elements must be unique – no two elements can have the same value.	
- The elements are unordered.	
- The elements are pairs.	
A: The elements are pairs.	

Q: What method can be used to add a group of elements to a set?
- add	
- addgroup	
- update	
- Elements must be added one at a time.	
A: update	

Q: What is the process used to convert an object to a stream of bytes that can be saved in a file?
- Pickling	
- Streaming	
- Writing	
- Dumping	
A: Pickling	

Q: You would typically use a for loop to iterate over the elements in a set.
- True
- False
A: True

Q: Sets are immutable.
- True
- False
A: False

Q: Sets are created using curly braces {}.
- True
- False
A: False

Q: The set remove and discard methods behave differently only when a specified item is not found in the set.
- True
- False
A: True

Q: A dictionary can include the same value several times, but cannot include the same key several times.
- True
- False
A: True

Q: The union of two sets is a set that contains only the elements that appear in both sets.
- True
- False
A: False

Q: The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.
- True
- False
A: True

Q: The index of the first element in a set is 0.
- True
- False
A: False

Q: The index of the first key-value pair in a dictionary is 0.
- True
- False
A: False

Q: The issubset method can be used to determine whether set1 is a subset of set2.
- True
- False
A: True

Q: A(n) _______________ is an object that holds multiple unique items of data in an unordered manner.
A: set

Q: The _______________ of two sets is a set that contains all the elements of both sets.
A: union

Q: The built-in function _______________ returns the number of items in a set.
A: len

Q: To add a single item to a set, you can use the set method _______________.
A: add

Q: Each element in a(n) _______________ has two parts: a key and a value.
A: dictionary

Q: The elements in a dictionary are not stored in a specific order. Therefore a dictionary is not a(n) _______________.
A: sequence

Q: To determine whether a key is not included in a dictionary, or an element is not included in a set, you can use the _______________ operator.
A: not in

Q: The _______________ method returns a value associated with a specified key and if found, removes that key-value pair from the dictionary.
A: pop

Q: The _______________ method clears the contents of a dictionary.
A: clear

Q: To write an object to a file, you use the _______________ function of the _______________ module.
A: dump, pickle

Q: What are the valid indexes for the string ‘New York’?
- 0 through 7
- 0 through 8
- -1 through -8
- -1 through 6
A: 0 through 7

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[ :4]
- ‘7’
- ‘1357’
- ‘1357 ‘
- Invalid code
A: ‘1357’

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[4: ]
- ‘1357’
- ‘Country Ln.’
- ‘ Country Ln.‘
- Invalid code
A: ‘ Country Ln.‘

Q: What will be assigned to the string variable even after the execution of the following code?
special = ‘0123456789’
even = special[0:10:2]
- ‘13579’
- ‘2468’
- ‘02468’
- Invalid code
A: ‘02468’

Q: What will be assigned to s_string after the execution of the following code?
special = ‘1357 Country Ln.’
s_string = special[-3: ]
- ‘531’
- ‘Ln.’
- ‘ Ln.’
- ‘7531’
A: ‘Ln.’

Q: If the start index is _____ the end index, the slicing expression will return an empty string.
- equal to
- less than
- greater than
- not equal to
A: greater than

Q: Which of the following string methods can be used to determine if a string contains only ‘\n’ characters?
- ischar()	
- isalpha()	
- istab()	
- isspace()
A: isspace()

Q: What is the return value of the string method lstrip()?
- The string with all whitespace removed
- The string with all leading spaces removed
- The string with all leading tabs removed
- The string with all leading whitespaces removed
A: The string with all leading whitespaces removed

Q: What will be assigned to the string variable pattern after the execution of the following code?
i = 3
pattern = ‘z’ * (5*i)
- ‘zzzzzzzzzzzzzzz’
- ‘zzzzz’
- Error: ‘*’ operator used incorrectly
- The right side of the ‘*’ must be an integer.
A: ‘zzzzzzzzzzzzzzz’

Q: Which list will be referenced by the variable list_strip after the execution of the following code?
list_string = ’03/07/2008’
list_strip = list_string.split(‘/’)
- [‘3’, ‘7’, ‘2008’]
- [‘03’, ‘07’, ‘2008’]
- [‘3’, ‘/’, ‘7’, ‘/’, ‘2008’]
- [‘03’, ‘/’, ‘07’, ‘/’, ‘2008’]
A: [‘03’, ‘07’, ‘2008’]

Q: What is the first negative index in a string?
- 0	
- -1	
- -0	
- Size of the string minus one	
A: -1	

Q: Which method would you use to determine whether a substring is present in a string?
- endswith(substring)	
- find(substring)	
- replace(string, substring)	
- startswith(substring)	
A: find(substring)	

Q: Which method would you use to determine whether a substring is the suffix of a string?
- endswith(substring)	
- find(substring)	
- replace(string, substring)	
- startswith(substring)	
A: endswith(substring)	

Q: What is the value of the variable string after the execution of the following code?
string = 'abcd'
string.upper()
- 'abcd'	
- 'Abcd'	
- 'ABCD'	
- Invalid code	
A: 'ABCD'	

Q: What is the value of the variable string after the execution of the following code?
string = 'Hello'
string += ' world'
- 'Hello'	
- ' world'	
- 'Hello world'	
- Invalid code	
A: 'Hello world'	

Q: Invalid indexes do not cause slicing expressions to raise an exception.
- True
- False
A: True

Q: Indexing works with both strings and lists.
- True
- False
A: True

Q: Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth.
- True
- False
A: False

Q: The index – 1 identifies the last character in a string.
- True
- False
A: True

Q: In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.
- True
- False
A: True

Q: An expression of the form string[i] = 'i' is a valid expression.
- True
- False
A: False

Q: If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands.
- True
- False
A: True

Q: When accessing each character in a string, such as for copying purposes, you would typically use a while loop.
- True
- False
A: False

Q: If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.
- True
- False
A: True

Q: The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters.
- True
- False
A: False

Q: Each character in a string has a(n) _______________ which specifies its position in the string.
A: index

Q: A(n) _______________ exception will occur if you try to use an index that is out of range for a particular string.
A: IndexError

Q: Strings are _______________, which means that once a string is created, it cannot be changed.
A: immutable

Q: A(n) _______________ is a span of characters that are taken from within a string.
A: slice

Q: The _______________ operator can be used to determine whether one string is contained in another string.
A: in

Q: The _______________ method returns true if the string contains only numeric digits.
A: isdigit()

Q: When the operand on the left side of the * symbol is a string and the operand on the right side is an integer, it becomes the _______________ operator.
A: repetition

Q: The _______________ method returns the list of the words in the string.
A: split()

Q: The _______________ method returns a copy of the string with all alphabetic letters converted to lower case.
A: lower()

Q: The third number in string slicing brackets represents the _______________ value.
A: step

Q: What are the data items in the list called?
- data
- elements
- items
- values
A: elements

Q: Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2)
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- [1, 3, 5, 7, 9]
- [2, 4, 6, 8]
- [0, 2, 4, 6, 8]
A: [0, 2, 4, 6, 8]

Q: What would you use if an element is to be removed from a specific index?
- del statement
- remove method
- index method
- slice method
A: del statement

Q: What is the first negative index in a list?
- 0	
- -1	
- -0	
- Size of the string or list minus one	
A: -1	

Q: What method can be used to place an item in the list at a specific index?
- append	
- index	
- insert	
- Add	
A: insert	

Q: What would be the value of the variable list after the execution of the following code?
list = [1, 2]
list = list * 3
- [1, 2] * 3	
- [3, 6]	
- [1, 2, 1, 2, 1, 2]	
- [[1, 2], [1, 2], [1, 2]]	
A: [1, 2, 1, 2, 1, 2]	

Q: What would be the value of the variable list after the execution of the following code?
list = [1, 2, 3, 4]
list[3] = 10
- [1, 2, 3, 10]	
- [1, 2, 10, 4]	
- [1, 10, 10, 10]	
- invalid code
A: [1, 2, 3, 10]	

Q: What method or operator can be used to concatenate lists?
- *	
- +	
- %	
- concat	
A: +	

Q: What would be the value of the variable list2 after the execution of the following code?
list1 = [1, 2, 3]
list2 = list1
list1 = [4, 5, 6]
- [1, 2, 3]	
- [4, 5, 6]	
- [1, 2, 3, 4, 5, 6]	
- invalid code	
A: [4, 5, 6]	

Q: What would be the value of the variable list2 after the execution of the following code?
list1 = [1, 2, 3]
list2 = []
for element in list1
list2.append(element)
list1 = [4, 5, 6]
- [1, 2, 3]	
- [4, 5, 6]	
- [1, 2, 3, 4, 5, 6]	
- invalid code	
A: [1, 2, 3]	

Q: When working with multiple sets of data, one would typically use a(n) _____.
- list	
- tuple	
- nested list	
- Sequence	
A: nested list	

Q: The primary difference between a tuple and list is that _____.
- when creating a tuple you don’t use commas to separate elements	
- a tuple can only include string elements	
- a tuple cannot include lists as elements	
- once a tuple is created, it cannot be changed	
A: once a tuple is created, it cannot be changed	

Q: What is the advantage of using tuples over lists?
- Tuples are not limited in size.	
- Tuples can include any data type as an element.	
- Processing a tuple is faster than processing a list.	
- There is no advantage.	
A: Processing a tuple is faster than processing a list.	

Q: What method can be used to convert a list to a tuple?
- append	
- tuple	
- insert	
- list	
A: tuple	

Q: What method can be used to convert a tuple to a list?
- append	
- tuple	
- insert	
- list	
A: list	

Q: Invalid indexes do not cause slicing expressions to raise an exception.
- True
- False
A: True

Q: Lists are dynamic data structures such that items may be added to them or removed from them.
- True
- False
A: True

Q: Arrays, which most other programming languages allow, have much more capabilities than list structures.
- True
- False
A: False

Q: A list cannot be passed as an argument to a function.
- True
- False
A: False

Q: The remove method removes all occurrences of the item from a list.
- True
- False
A: False

Q: The sort method rearranges the elements of a list so they appear in ascending or descending order.
- True
- False
A: False

Q: The first step in calculating the average of the values in a list is to get the total of the values.
- True
- False
A: True

Q: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.
- True
- False
A: False

Q: The index – 1 identifies the last element in a list.
- True
- False
A: True

Q: In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.
- True
- False
A: True

Q: A(n) _______________ is an object that holds multiple items of data.
A: sequence

Q: Each element in a tuple has a(n) _______________ that specifies its position in the tuple.
A: index

Q: The built-in function _______________ returns the length of a sequence.
A: len

Q: Tuples are _______________ sequences, which means that once a tuple is created, it cannot be changed.
A: immutable

Q: A(n) _______________ is a span of items that are taken from a sequence.
A: slice

Q: Lists are _______________, which means their elements can be changed.
A: mutable

Q: The _______________ method is commonly used to add items to a list.
A: append

Q: The _______________ exception is raised when a search item is not in the list being searched.
A: ValueError

Q: The _______________ method reverses the order of the items in the list.
A: reverse

Q: The _______________ function returns the item that has the lowest value in the sequence.
A: min

Q: Programs are commonly referred to as _____.
- system software
- software
- application software
- utility programs
A: software

Q: Which of the following is considered to be the world’s first programmable electronic computer?
- IBM
- DELL
- ENIAC
- GATEWAY
A: ENIAC

Q: Where does a computer store a program and the data that the program is working with while the program is running?
- Main memory
- CPU
- Disk
- Microprocessor
A: Main memory

Q: Which one of the following is not a microprocessor manufacturing company?
- Intel
- Dell
- AMD
- Motorola
A: Dell

Q: What type of volatile memory is usually used only for temporary storage while running a program?
- ROM
- TMM
- RAM
- TVM
A: RAM

Q: Which computer language uses short words known as mnemonics for writing programs?
- Assembly
- Java
- Pascal
- Visual Basic
A: Assembly

Q: The process known as the _____ cycle is used by the CPU to execute instructions in a program.
- decode-fetch-execute
- decode-execute-fetch
- fetch-decode-execute
- fetch-execute-decode
A: fetch-decode-execute

Q: Which language from the following list is referred to as a low-level language?
- C++
- Assembly language
- JAVA
- Python
A: Assembly language

Q: The following is an example of an instruction written in which computer language? 10110000
- Assembly language
- JAVA
- Machine language
- C #
A: Machine language

Q: What is the encoding technique called that is used to store negative numbers in the computer’s memory?
- Unicode
- ASCII
- floating-point notation
- two’s complement
A: two’s complement

Q: The _____ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer memory.
- Unicode
- ASCII
- ENIAC
- twos complement
A: ASCII

Q: What is the largest value that can be stored in one byte?
- 255
- 128
- 8
- 65535
A: 255

Q: The smallest storage location in a computer’s memory is known as a _____.
- byte
- ketter
- switch
- bit
A: bit

Q: The disk drive is a secondary storage device that stores data by _____ encoding it onto circular disks.
- electrically
- magnetically
- digitally
- optically
A: magnetically

Q: Which of these is not a major component of a typical computer system?
- Central processing unit
- Main memory
- Operating system
- Secondary storage devices
A: Operating system

Q: A software developer is the person with the training to design, create, and test computer programs.
- True
- False
A: True

Q: A computer is a single device that performs different types of tasks for its users.
- True
- False
A: False

Q: The CPU is able to quickly access data stored at any random location in ROM.
- True
- False
A: False

Q: All programs are normally stored in ROM and loaded into RAM as needed for processing.
- True
- False
A: False

Q: The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.
- True
- False
A: True

Q: The CPU understands instructions written in a binary machine language.
- True
- False
A: True

Q: A bit that is turned off is represented by the value -1.
- True
- False
A: False

Q: The main reason for using secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.
- True
- False
A: True

Q: RAM is a volatile memory used for temporary storage while a program is running.
- True
- False
A: True

Q: The Python language uses a compiler, which is a program that both translates and executes the instructions in a high level language.
- True
- False
A: False

Q: A(n) _______________ is a set of instructions that a computer follows to perform a task.
A: program

Q: The term _______________ refers to all of the physical devices that a computer is made of.
A: hardware

Q: The _______________ is the part of a computer that actually runs programs and is the most important component in a computer.
A: central processing unit or CPU

Q: _______________ are small central processing unit chips.
A: Microprocessors

Q: Main memory is commonly known as _______________.
A: random-access memory or RAM

Q: _______________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer.
A: Secondary storage

Q: A disk drive stores data by _______________ encoding it onto a circular disk.
A: magnetically

Q: The disadvantages of a(n) _______________ are that it only holds small amounts of data, is slow to access data, and can be unreliable.
A: floppy disk

Q: The Python _______________ is a program that can read Python programming statements and execute them.
A: interpreter

Q: In _______________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.
A: script

Q: What type of error produces incorrect results but does not prevent the program from running?
- syntax
- logic
- grammatical
- human
A: logic

Q: The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.
- five
- four
- three
- six
A: five

Q: What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?
- Flowchart
- Algorithm
- Code
- Pseudocode
A: Pseudocode

Q: A(n) _____ is a diagram that graphically depicts the steps that take place in a program.
- flowchart
- algorithm
- code
- pseudocode
A: flowchart

Q: The _____ 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.
- input
- output
- eval_input
- string_input
A: input

Q: The line continuation character is a _____.
- #
- %
- &
- \
A: \

Q: Which mathematical operator is used to raise five to the second power in Python?
- /
- **
- ^
- ~
A: **

Q: In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.
- stop
- end
- separator
- newLine
A: end

Q: After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752
- int
- float
- str
- currency
A: float

Q: After executing the following statement, the variable price will reference the value _____. price = int(68.549)
- 68
- 69
- 68.55
- 68.54
A: 68

Q: The output of the following print statement is: print ‘I\’m ready to begin’
- Im ready to begin
- I\’m ready to begin
- I’m ready to begin
- ‘I\’m ready to begin’
A: I’m ready to begin

Q: If value1 is 2.0 and value2 is 12, what is the output of the following command?
print(value1 * value2)
- 24
- value1 * value2
- 24.0
- 2.0 * 12
A: 24.0

Q: The _____ built-in function is used to read a number that has been typed on the keyboard.
- input()
- read()
- get()
- keyboard()
A: input()

Q: What is the output of the following print statement?
print(‘The path is D:\\sample\\test.’)
- ‘The path is D:\\sample\\test.’
- The path is D:\\sample\\test.
- The path is D\\sample\\test.
- The path is D:\sample\test.
A: The path is D:\sample\test.

Q: What symbol is used to mark the beginning and end of a string?
- Slash
- Asterisk
- Quotation
- Comma
A: Quotation

Q: Comments in Python begin with the # character.
- True
- False
A: True

Q: When using the camelCase naming convention, the first word of the variable name is written in lowercase letters and the first character of the second and subsequent words are written in uppercase letters.
- True
- False
A: True

Q: According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.
- True
- False
A: False

Q: Python allows programmers to break a statement into multiple lines.
- True
- False
A: True

Q: Python formats all floating-point numbers to two decimal places when outputting using the print statement.
- True
- False
A: False

Q: A flowchart is a tool that programmers use to design programs.
- True
- False
A: True

Q: In Python, math expressions are evaluated from left to right, no matter what the operators are.
- True
- False
A: False

Q: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.
- True
- False
A: True

Q: The \t escape character causes the output to skip over to the next horizontal tab.
- True
- False
A: True

Q: _______________ are notes of explanation that document lines or sections of a program.
A: Comments

Q: The % symbol is the remainder operator and it is also known as the _______________ operator.
A: modulus

Q: A(n) _______________ character is a special character that is preceded with a backslash, appearing inside a string literal.
A: escape

Q: The _______________ specifier is a special set of characters that specify how a value should be formatted.
A: formatting

Q: The result of the expression 12.3 + 6.7 is _______________.
A: 19.0

Q: When applying the .3f formatting specifier to the following number, 76.15854, the result is _______________.
A: 76.159

Q: A(n) _______ is a single task that the program must perform in order to satisfy the customer.
A: software requirement

Q: A(n) ________ is a name that represents a value stored in the computer’s memory.
A: variable

Q: Python uses _______________ to categorize values in memory.
A: data types

Q: When the + operator is used with two strings, it performs string _______________.
A: concatenation

Q: What is a group of statements that exists within a program for the purpose of performing a specific task?
- function
- subtask
- procedure
- subprogram
A: function

Q: The first line in the function definition is known as the function _____.
- header
- block
- return
- parameter
A: header

Q: The _____ design technique can be used to break down an algorithm into functions.
- subtask
- block
- top-down
- simplification
A: top-down

Q: A set of statements that belong together as a group and contribute to the function definition is known as a(n) _____.
- header
- block
- return
- parameter
A: block

Q: A(n) _____ chart is also known as a structured chart.
- flow
- data
- hierarchy
- organizational
A: hierarchy

Q: A(n) _____ variable is created inside a function.
- global
- constant
- defined
- local
A: local

Q: The _____ of a local variable is the function in which the variable is created.
- global
- defined
- local
- scope
A: scope

Q: A(n) _____ is any piece of data that is passed into a function when the function is called.
- global
- argument
- scope
- parameter
A: argument

Q: A(n) _____ is a variable that receives an argument that is passed into a function.
- global
- argument
- scope
- parameter
A: parameter

Q: The _____ argument specifies which parameter the argument should be passed into.
- keyword
- local
- global
- string
A: keyword

Q: A(n) ____ variable is accessible to all the functions in a program file.
- keyword
- local
- global
- string
A: global

Q: A(n) _____ constant is a global name that references a value that cannot be changed.
- keyword
- local
- global
- string
A: global

Q: When a function is called by its name, then it is _____.
- executed
- located
- defined
- exported
A: executed

Q: It is recommended that programmers should avoid using _____ variables in a program when possible.
- local
- global
- string global
- keyword
A: global

Q: A variable’s _____ is the part of a program in which the variable may be accessed.
- global		
- argument	
- scope	
- local	
A: scope	

Q: Python function names follow the same rules for naming variables.
- True
- False
A: True

Q: The function header marks the beginning of the function definition.
- True
- False
A: True

Q: A function definition specifies what a function does and causes the function to execute.
- True
- False
A: False

Q: The hierarchy chart shows all the steps that are taken inside a function.
- True
- False
A: False

Q: A local variable can be accessed from anywhere in the program.
- True
- False
A: False

Q: Different functions can have local variables with the same names.
- True
- False
A: True

Q: Python allows for passing multiple arguments to a function.
- True
- False
A: True

Q: To assign a value to a global variable in a function, the global variable must first be declared in the function.
- True
- False
A: True

Q: The value assigned to a global constant can be changed in the mainline logic.
- True
- False
A: False

Q: One of the reasons not to use global variables is that it makes a program hard to debug.
- True
- False
A: True

Q: The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
A: divide and conquer

Q: The code for a function is known as a function _______________.
A: definition

Q: A function header begins with the keyword _______________ followed by the name of the function.
A: def

Q: The main function contains a program’s _______________ logic, which is the overall logic of the program.
A: mainline

Q: In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
A: rectangle

Q: The top-down design breaks down the overall task of the program into a series of _______________.
A: subtasks

Q: A(n) _______________ chart is a visual representation of the relationships between functions.
A: hierarchy

Q: Arguments are passed by _______________ to the corresponding parameter variables in the function.
A: position

Q: A variable is visible only to statements in the variable’s _______________.
A: scope

Q: A(n) _____ structure is a logical design that controls the order in which a set of statements execute.
- function
- control
- sequence
- iteration
A: control

Q: The decision structure that has two possible paths of execution is known as _____.
- single alternative
- double alternative
- dual alternative
- two alternative
A: dual alternative

Q: Multiple Boolean expressions can be combined by using a logical operator to create _____ expressions.
- sequential
- logical
- compound
- mathematical
A: compound

Q: When using the _____ operator, one or both subexpressions must be true for the compound expression to be true.
- Or
- And
- Not
- Maybe
A: Or

Q: Which logical operators perform short-circuit evaluation?
- or, not
- not, and
- or, and
- and, or, not
A: or, and

Q: Which of the following is the correct if clause to determine whether y is in the range 10 through 50?
- if 10 < y or y > 50
- if 10 > y and y < 50
- if y > 10 and y < 50
- if y > 10 or y < 50
A: if y > 10 and y < 50

Q: A Boolean variable can reference one of two values: _____.
- yes or no
- true or false
- T or F
- Y or N
A: true or false

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8?
x < y or z > x
- true
- false
- 8
- 5
A: true

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y and z > x
- true
- false
- 8
- 5
A: false

Q: What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? not (x < y or z > x) and y < z
- true
- false
- 8
- 5
A: false

Q: What does the following expression mean? x <= y
- x is less than y
- x is less than or equal to y
- x is greater than y
- x is greater than or equal to y
A: x is less than or equal to y

Q: Which of the following is the correct if clause to use to determine whether choice is other than 10?
- if choice != 10:
- if choice != 10
- if choice <> 10:
- if choice <> 10
A: if choice != 10:

Q: When using the _____ operator, both subexpressions must be true for the compound expression to be true.
- or
- and
- not
- maybe
A: and

Q: In Python, the _____ symbol is used as the not-equal-to operator.
- ==	
- <>	
- <=	
- !=	
A: !=	

Q: In Python the _____ symbol is used as the equality operator.
- ==	
- =	
- >=	
- <=	
A: ==	

Q: The if statement causes one or more statements to execute only when a Boolean expression is true.
- True
- False
A: True

Q: The Python language is not sensitive to block structuring of code.
- True
- False
A: False

Q: Python allows you to compare strings, but it is not case sensitive.
- True
- False
A: False

Q: Nested decision structures are one way to test more than one condition.
- True
- False
A: True

Q: Python uses the same symbols for the assignment operator and the equality operator.
- True
- False
A: False

Q: The not operator is a unary operator and it must be a compound expression.
- True
- False
A: False

Q: Short-circuit evaluation is performed with the not operator.
- True
- False
A: False

Q: Expressions that are tested by the if statement are called Boolean expressions.
- True
- False
A: True

Q: Decision structures are also known as selection structures.
- True
- False
A: True

Q: An action in a single alternative decision structure is performed only when the condition is true.
- True
- False
A: True

Q: The _______________ statement is used to create a decision structure.
A: if

Q: In flowcharting, the _______________ symbol is used to represent a Boolean expression.
A: diamond

Q: A(n) _______________ decision structure provides only one alternative path of execution.
A: single alternative

Q: In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true.
A: conditionally

Q: A(n) _______________ operator determines whether a specific relationship exists between two values.
A: relational

Q: A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false.
A: if-else

Q: 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.
A: if-elif-else

Q: The logical _______________ operator reverses the truth of a Boolean expression.
A: not

Q: Boolean variables are commonly used as _______________ to indicate whether a specific condition exists.
A: flags

Q: A(n) _______________ expression is made up of two or more Boolean expressions.
A: compound

Q: What is the disadvantage of coding in one long sequence structure?
- Duplicated code makes the program faster to write.
- Writing a long sequence of statements is error prone.
- If parts of the duplicated code have to be corrected, the correction has to be made many times.
- It does not make use of decision structures.
A: If parts of the duplicated code have to be corrected, the correction has to be made many times.

Q: What type of loop structure repeats the code a specific number of times?
- Condition-controlled loop
- Number-controlled loop
- Count-controlled loop
- Boolean-controlled loop
A: Count-controlled loop

Q: What type of loop structure repeats the code based on the value of the Boolean expression?
- Condition-controlled loop
- Number-controlled loop
- Count-controlled loop
- Boolean-controlled loop
A: Condition-controlled loop

Q: What is the format for the while clause in Python?
- while condition
- while condition :
- while condition statement
- while condition : statement
A: while condition :

Q: What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)
- 2, 3, 4, 5, 6, 7, 8, 9
- 2, 5, 8
- 2, 4, 6, 8
- 1, 3, 5, 7, 9
A: 2, 4, 6, 8

Q: What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)
- 1, 2, 3, 4
- 0, 1, 2, 3, 4
- 1, 2, 3
- 0, 1, 2, 3
A: 0, 1, 2, 3

Q: The variable used to keep the running total is called a(n) _____.
- Accumulator
- Total
- running total
- grand total
A: Accumulator

Q: What is not an example of an augmented assignment operator?
- *=
- /=
- -=
- <=
A: <=

Q: _____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.
- Input validation
- Correcting data
- Data validation
- Correcting input
A: Input validation

Q: The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.
- priming read
- first input
- loop set read
- loop validation
A: priming read

Q: What is the structure that causes a statement or a set of statements to execute repeatedly?
- Sequence
- Decision
- Module
- Repetition

12 When will the following loop terminate? while keep_on_going != 999 :
a. When keep_on_going refers to a value less than 999
b. When keep_on_going refers to a value greater than 999
*c. When keep_on_going refers to a value equal to 999
d. When keep_on_going refers to a value not equal to 999
A: Repetition

12 When will the following loop terminate? while keep_on_going != 999 :
a. When keep_on_going refers to a value less than 999
b. When keep_on_going refers to a value greater than 999
*c. When keep_on_going refers to a value equal to 999
d. When keep_on_going refers to a value not equal to 999

Q: In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.
- sequence
- variable
- value
- list
A: list

Q: In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.
- target variable	
- loop variable	
- for variable	
- count variable	
A: target variable	

Q: Which of the following represents an example to calculate the sum of the numbers (accumulator)?
- total + number = total	
- number += number	
- total += number	
- total = number	
A: total += number	

Q: Reducing duplication of code is one of the advantages of using a loop structure.
- True
- False
A: True

Q: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.
- True
- False
A: True

Q: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
- True
- False
A: True

Q: The first line in the while loop is referred to as the condition clause.
- True
- False
A: False

Q: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
- True
- False
A: False

Q: Both of the following for clauses would generate the same number of loop iterations:
for num in range(4):
for num in range(1,5):
- True
- False
A: True

Q: The integrity of a program’s output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data.
- True
- False
A: True

Q: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.
- True
- False
A: False

Q: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.
- True
- False
A: True

Q: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.
- True
- False
A: True

Q: A(n) _______________ structure causes a statement or set of statements to execute repeatedly.
A: repetition

Q: A(n) _______________-controlled loop causes a statement or set of statements to repeat as long as a condition is true.
A: condition

Q: The while loop is known as a(n) _______________ loop because it tests conditions before performing an iteration.
A: pretest

Q: A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition false.
A: infinite

Q: In Python, you would use the _______________ statement to write a count-controlled loop.
A: for

Q: A(n) _______________ total is a sum of numbers that accumulates with each iteration of a loop.
A: running

Q: A(n) _______________ is a special value that marks the end of a sequence of items.
A: sentinel

Q: The acronym _______________ refers to the fact that the computer cannot tell the difference between good data and bad data.
A: GIGO

Q: A(n) _______________ validation loop is sometimes called an error trap or an error handler.
A: input

Q: The _______________ function is a built-in function that generates a list of integer values.
A: range

Q: The Python library functions that are built into the Python _____ can be used by simply calling the function.
- code
- compiler
- linker
- interpreter
A: interpreter

Q: Python comes with _____ functions that have been already prewritten for the programmer.
- standard
- library
- custom
- built-in
A: standard

Q: Which of the following statements causes the interpreter to load the contents of the random module into memory?
- load random
- import random
- upload random
- download random
A: import random

Q: Which one of the following will assign a random number in the range of 1 through 50 to the variable number?
- random(1,50) = number
- number = random.randint(1, 50)
- randint(1, 50) = number
- number = random(range(1, 50))
A: number = random.randint(1, 50)

Q: What is the result of the following statement? x = random.randint(5, 15) * 2
- A random integer from 5 to 15, multiplied by 2, assigned to the variable x
- A random integer from 5 to 15 assigned to the variable x
- A random integer from 5 to 15, selected in 2 steps, assigned to the variable x
- A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
A: A random integer from 5 to 15, multiplied by 2, assigned to the variable x

Q: What type of value is returned by the functions random and uniform?
- integer
- number
- float
- double
A: float

Q: In a value-returning function, the value of the expression that follows the key word _____ will be sent back to the part of the program that called the function.
- def
- return
- sent
- result
A: return

Q: What type of function can be used to determine whether a number is even or odd?
- even
- odd
- math
- Boolean
A: Boolean

Q: The Python standard library’s _____ module contains numerous functions that can be used in mathematical calculations.
- math
- string
- random
- number
A: math

Q: The _______ functions returns the largest integer that is less than or equal to x?
- floor
- ceil
- lesser
- greater
A: floor

Q: What makes it easier to reuse the same code in more than one program?
- Mods
- Procedures
- Modules
- Functions
A: Modules

Q: In a menu-driven program, what statement is used to determine and carry out the user’s desired action?
- if-else
- if-elif-else
- while
- for
A: if-elif-else

Q: A value-returning function is _____.
- a single statement that perform a specific task
- called when you want the function to stop
- a function that will return a value back to the part of the program that called it
- a function that receives a value when it is called
A: a function that will return a value back to the part of the program that called it

Q: What does the following statement mean? num1, num2 = get_num()
- The function get_num() is expected to return a value each for num1 and num2.	
- The function get_num() is expected to return a value and assign it to num1 and num2.	
- Statement will cause a syntax error.	
- Statement will cause a run-time error.	
A: The function get_num() is expected to return a value each for num1 and num2.	

Q: Given the following function definition, what would the statement print magic(5) display?
def magic(num):
return num + 2 * 10
- 70	
- 25	
- Statement will cause a syntax error.	
- Statement will cause a run-time error.	
A: 25	

Q: A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program.
- True
- False
A: True

Q: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
- True
- False
A: True

Q: Unlike other languages, in Python, the number of values a function can return is limited to one.
- True
- False
A: False

Q: In Python, one can have a list of variables on the left side of the assignment operator.
- True
- False
A: True

Q: In Python, there is no restriction on the name of a module file.
- True
- False
A: False

Q: The randrange function returns a randomly selected value from a specific sequence of numbers.
- True
- False
A: True

Q: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
- True
- False
A: False

Q: In a menu-driven program, a loop structure is used to determine the menu item the user selected.
- True
- False
A: False

Q: The math function, atan(x), returns one tangent of x in radians.
- True
- False
A: False

Q: The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
- True
- False
A: True

Q: Functions in the standard library are stored in files that are known as _______________.
A: modules

Q: The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
A: black box

Q: To refer to a function in a module, in our program we have to use the _______________ notation.
A: dot

Q: A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
A: return

Q: The _______________ chart is an effective tool that programmers use for designing and documenting functions.
A: IPO

Q: The ‘P’ in the acronym IPO refers to _______________.
A: processing

Q: In Python, a module’s file name should end in _______________.
A: .py

Q: A(n) _______________ program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.
A: menu-driven

Q: The approach of _______________ makes the program easier to understand, test, and maintain.
A: modularization

Q: The return values of the trigonometric functions in Python are in _______________.
A: radians

Q: Which of these is associated with a specific file and provides a way for the program to work with that file?
- Filename
- Extension
- File object
- File variable
A: File object

Q: What do you call the process of retrieving data from a file?
- Retrieving data
- Reading data
- Input data
- Get data
A: Reading data

Q: What happens when a piece of data is written to a file?
- Data is copied from a variable in RAM to a file.
- Data is copied from a variable in the program to a file.
- Data is copied from the program to a file.
- Data is copied from a file object to a file.
A: Data is copied from a variable in RAM to a file.

Q: Which step creates a connection between a file and a program?
- Open the file.
- Read the file.
- Process the file.
- Close the file.
A: Open the file.

Q: How many types of files are there?
- One
- Two
- Three
- Four
A: Two

Q: A(n) _____ access file is also known as a direct access file.
- sequential
- random
- numbered
- text
A: random

Q: What type of file access jumps directly to any piece of data in a file without reading the data that came before it?
- Sequential	
- Random	
- Number	
- Text
A: Random	

Q: Which one of the following mode specifiers will open a file but will not let you change the file or write to it?
- ‘w’
- ‘r’
- ‘a’
- 'e'
A: ‘r’

Q: Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?
- ‘w’
- ‘r’
- ‘a’
- ‘e’
A: ‘w’

Q: Assume that the customer file references a file object, and the file was opened using the ‘w’ mode specifier. How would you write the string ‘Mary Smith’ to the file?
- customer_file.write(‘Mary Smith’)
- customer.write(‘w’,‘Mary Smith’)
- customer.input(‘Mary Smith’)
- customer.write(‘Mary Smith’)
A: customer.write(‘Mary Smith’)

Q: When a file has been opened using the ‘r’ mode specifier, which method will return the file’s contents as a string?
- write
- input
- get
- read
A: read

Q: Which method could be used to strip specific characters from the end of a string?
- estrip
- rstrip
- strip
- remove
A: rstrip

Q: A(n) _____ method could be used to convert a numeric value to a string?
- str
- value
- num
- chr
A: str

Q: Which method will return an empty string when it has attempted to read beyond the end of a file?
- read	
- getline	
- input	
- readline	
A: readline	

Q: What statement can be used to handle some of the run-time errors in a program?
- exception statement	
- try statement	
- try/except statement	
- exception handler statement	
A: try/except statement	

Q: If a file with the specified name already exists when the file is opened, and the file is opened in 'w' mode, then an alert will appear on the screen.
- True
- False
A: False

Q: When a piece of data is read from a file, it is copied from the file into the program.
- True
- False
A: False

Q: Closing a file disconnects the communication between the file and the program.
- True
- False
A: True

Q: Python allows the programmer to work with text and number files.
- True
- False
A: False

Q: In Python, there is nothing that can be done if the program tries to access a file to read that does not exist.
- True
- False
A: False

Q: The ZeroDivisionError exception is raised when the program attempts to perform a division by zero.
- True
- False
A: True

Q: An exception handler is a piece of code that is written using the try/except statement.
- True
- False
A: True

Q: If the last line in a file is not terminated with a \n, the readline method will return the line without a \n.
- True
- False
A: True

Q: Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.
- True
- False
A: True

Q: It is possible to create a while loop that determines when the end of a file has been reached.
- True
- False
A: True

Q: When a program needs to save data for later use, it writes the data in a(n) _______________.
A: file

Q: Programmers usually refer to the process of _______________ data in a file as “writing data to” the file.
A: saving

Q: The term ___________ file is used to describe a file to which data is written.
A: output

Q: The term __________ file is used to describe a file from which the program gets data.
A: input

Q: A(n) ____________ file contains data that has been encoded as text, using a scheme such as ASCII.
A: text

Q: A(n) __________ file contains data that has not been converted to text.
A: binary

Q: A(n) _______________ access file retrieves data from the beginning of the file to the end of the file.
A: sequential

Q: A filename _______________ is a short sequence of characters that appear at the end of a filename preceded by a period.
A: extension

Q: A(n) ___________ gives information regarding the line number(s) that caused an exception.
A: traceback

Q: A(n) __________ includes one or more statements that can potentially raise an exception.
A: try block