True/False: 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: 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.
Front
True
Back
True/False: 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):
Front
True
Back
True/False: Nested decision structures are one way to test more than one condition.
Front
True
Back
The Python library functions that are built into the Python ________ can be used by simply calling the function.
Front
interpreter
Back
If value1 is 2.0 and value2 is 12, what is the output of the following command?
print(value1 * value2)
Front
24.0
Back
True/False: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.
Front
True
Back
In Python, the ________ symbol is used as the not-equal-to operator.
Front
!=
Back
What type of loop structure repeats the code based on the value of the Boolean expression?
Front
condition-controlled loop
Back
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
Front
True
Back
True/False: 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.
Front
True
Back
What does the following expression mean?
x <= y
Front
x is less than or equal to y
Back
True/False: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.
Front
False
Back
A(n) ________ variable is created inside a function.
Front
local
Back
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
Front
False
Back
True/False: An action in a single alternative decision structure is performed only when the condition is true.
Front
True
Back
What are the values that the variable num contains through the iterations of the following for loop?
for num in range(2, 9, 2):
Front
2,4,6,8
Back
What type of loop structure repeats the code a specific number of times?
Front
count-controlled loop
Back
True/False: The Python language is not sensitive to block structuring of code.
Front
False
Back
True/False: Python formats all floating-point numbers to two decimal places when outputting using the print statement.
Front
False
Back
True/False: Python allows programmers to break a statement into multiple lines.
Front
True
Back
True/False: In Python, math expressions are evaluated from left to right, no matter what the operators are.
Selected Answer
Front
False
Back
After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) ________ data type:
sold = 256.752
Front
Float
Back
What is the disadvantage of coding in one long sequence structure?
Front
If parts of the duplicated code have to be corrected, the correction has to be made many times.
Back
A Boolean variable can reference one of two values: ________.
Front
true or false
Back
True/False: The function header marks the beginning of the function definition.
Front
True
Back
True/False: Comments in Python begin with the # character.
Front
True
Back
True/False: Python allows you to compare strings, but it is not case sensitive.
Front
False
Back
True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.
Front
True
Back
True/False: A local variable can be accessed from anywhere in the program.
Front
false
Back
True/False: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
Front
False
Back
What is the structure that causes a statement or a set of statements to execute repeatedly?
Front
repitition
Back
What is the output of the following print statement?
print('The path is D:\\sample\\test.')
Front
The path is D:\sample\test
Back
True/False: The \t escape character causes the output to skip over to the next horizontal tab.
Front
True
Back
What is not an example of an augmented assignment operator?
Front
<=
Back
The variable used to keep the running total is called a(n) ________.
Front
accumulator
Back
Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?
Front
'w'
Back
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.
Front
end
Back
True/False: In Python, print statements written on separate lines do not necessarily output on separate lines.
Front
True
Back
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?
Front
psuedocode
Back
A ________ variable is accessible to all the functions in a program file
Front
global
Back
In Python the ________ symbol is used as the equality operator
Front
==
Back
Python comes with ________ functions that have been already prewritten for the programmer.
Front
standard
Back
True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
Front
True
Back
True/False: 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.
Front
True
Back
A(n) ________ is a diagram that graphically depicts the steps that take place in a program.
Front
flowchart
Back
A variable's ________ is the part of a program in which the variable may be accessed.
Front
scope
Back
When will the following loop terminate?
while keep_on_going != 999:
Front
When keep_on_going refers to a value equal to 999
Back
True/False: When function A calls function B, which in turn calls function A, it is known as indirect recursion.
Front
True
Back
True/False: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.
Front
True
Back
After the execution of the following statement, the variable price will reference the value ________.
price = int(68.549)
Front
68
Back
Section 2
(50 cards)
True/False: In Python, one can have a list of variables on the left side of the assignment operator
Front
true
Back
When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string?
Front
read
Back
In a dictionary, you use a(n) ________ to locate a specific value.
Front
key
Back
True/False: Python function names follow the same rules for naming variables.
Front
true
Back
What defines the depth of recursion?
Front
the number of times the function calls itself
Back
True/False: Different functions can have local variables with the same names
Front
true
Back
A(n) ________ is any piece of data that is passed into a function when the function is called
Front
argument
Back
Given the following function definition, what would the statement print(magic(5)) display?
def magic(num):
return num + 2 * 10
Front
25
Back
What would you use if an element is to be removed from a specific index?
Front
del statement
Back
True/False: One of the reasons not to use global variables is that it makes a program hard to debug.
Front
true
Back
True/False: A function definition specifies what a function does and causes the function to execute.
Front
false
Back
What would be the result of the following code?
ages = {'Aaron': 6, 'Kelly': 3, 'Abigail': 1}
value = ages['Brianna']
Front
KeyError
Back
What does the following statement mean?
num1, num2 = get_num()
Front
The function get_num() is expected to return a value each for num1 and num2.
Back
What makes it easier to reuse the same code in more than one program?
Front
modules
Back
Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?
Front
pop
Back
True/False: Python allows for passing multiple arguments to a function.
Front
True
Back
What is the process used to convert an object to a stream of bytes that can be saved in a file?
Front
pickling
Back
What are the data items in the list called?
Front
elements
Back
True/False: A recursive function must have some way to control the number of times it repeats
Front
true
Back
What is the value of the variable string after the execution of the following code?
myString = 'abcd'
myString = myString.upper()
Front
'ABCD'
Back
What method can be used to place an item in the list at a specific index?
Front
insert
Back
True/False: A problem can be solved with recursion if it can be broken into smaller problems that are identical in structure to the overall problem.
Front
true
Back
True/False: The hierarchy chart shows all the steps that are taken inside a function
Front
false
Back
True/False: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.
Front
false
Back
Which statement would you use to delete an existing key-value pair from a dictionary?
Front
del
Back
What would be the value of the variable list after the execution of the following code?
list= [1, 2]
list = list * 3
Front
[1, 2, 1, 2, 1, 2]
Back
What is a group of statements that exists within a program for the purpose of performing a specific task?
Front
function
Back
True/False: Lists are dynamic data structures such that items may be added to them or removed from them
Front
true
Back
Which list will be referenced by the variable number after the execution of the following code?
number = range(0, 9, 2)
Front
[0, 2, 4, 6, 8]
Back
True/False: The sort method rearranges the elements of a list so they appear in ascending or descending order.
Front
false
Back
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?
Front
customer.write('Mary Smith')
Back
A value-returning function is ________.
Front
a function that will return a value back to the part of the program that called it
Back
A set of statements that belong together as a group and contribute to the function definition is known as a(n) ________.
Front
block
Back
True/False: The remove method removes all occurrences of the item from a list.
Front
false
Back
True/False: Unlike other languages, in Python, the number of values a function can return is limited to one
Front
false
Back
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']
Front
Jimmy and jimmy are different
Back
In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function.
Front
return
Back
What method or operator can be used to concatenate lists?
Front
+
Back
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]
Front
[1,2,3]
Back
What is the result of the following statement?
x = random.randint(5, 15) * 2
Front
A random integer from 5 to 15, multiplied by 2, assigned to the variable x
Back
A ________ constant is a global name that references a value that cannot be changed.
Front
global
Back
What statement can be used to handle some of the run-time errors in a program?
Front
try/except statement
Back
What method can be used to convert a list to a tuple?
Front
tuple
Back
A(n) ________ is a variable that receives an argument that is passed into a function
Front
parameter
Back
True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.
Front
true
Back
The first line in the function definition is known as the function ________.
Front
header
Back
The Python standard library's ________ module contains numerous functions that can be used in mathematical calculations.
Front
math
Back
It is recommended that programmers should avoid using ________ variables in a program when possible
Front
global
Back
If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and ________.
Front
calls itself to solve the smaller problem
Back
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]
Front
[1, 2, 3]
Back
Section 3
(50 cards)
True/False: Using the radio buttons, the user can make multiple selections at one time.
Front
false
Back
Which widget will display multiple lines of text?
Front
message
Back
What will be assigned to the string variable even after the execution of the following code?
special = '0123456789'
even = special[0:10:2]
Front
'02468'
Back
The primary difference between a tuple and list is that ________.
Front
once a tuple is created, it cannot be changed
Back
Which method is automatically executed when an instance of the class is created in memory?
Front
__init__
Back
Which method would you use to determine whether a substring is present in a string?
Front
find(substring)
Back
True/False: The instances of a class share the data attributes in the class
Front
false
Back
Which list will be referenced by the variable list_string after the execution of the following code?
list_string = '03/07/2008'
list_string = list_string.split('/')
Front
['03', '07', '2008']
Back
True/False: The self parameter is required in every method of a class.
Front
true
Back
What attributes belong to a specific instance of the class?
Front
instance
Back
What types of programs are event-driven?
Front
GUI programs
Back
True/False: Python does not have GUI programming features built into the language itself.
Front
true
Back
What is the relationship called in which one object is a specialized version of another object?
Front
is a
Back
What method can be used to add a group of elements to a set?
Front
update
Back
What is another name for the accessor methods?
Front
getters
Back
What will be assigned to s_string after the execution of the following code?
special = '1357 Country Ln.'
s_string = special[ :4]
Front
'1357'
Back
What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?
Front
object
Back
True/False: A list cannot be passed as an argument to a function.
Front
false
Back
Which widget will create a rectangular area that can be used to display graphics?
Front
canvas
Back
What is the correct structure for creating a dictionary of month names to be accessed by month numbers?
Front
{ 1 : 'January', 2 : 'February', 3 : 'March' }
Back
True/False: A class might be thought of as a 'blueprint' that an object may be created from.
Front
true
Back
Which widget will create an area that displays one line of text or an image?
Front
label
Back
________ allow(s) a new class to inherit the members of the class it extends.
Front
Inheritance
Back
in order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the ________ operator.
Front
in
Back
True/False: Check buttons are displayed in groups and used to make mutually exclusive selections.
Front
false
Back
In which environment can a user determine the order in which things happen?
Front
GUI
Back
What is the value of the variable string after the execution of the following code?
string = 'Hello'
string += ' world'
Front
'Hello world'
Back
What concept involves a superclass and a subclass?
Front
inheritance
Back
What are the valid indexes for the string 'New York'?
Front
0 through 7
Back
What gives a program the ability to call the correct method depending on the type of object that is used to call it?
Front
polymorphism
Back
What would be the value of the variable list after the execution of the following code?
list = [1, 2, 3, 4]
list[3] = 10
Front
[1, 2, 3, 10]
Back
What is the number of the first index in a dictionary?
Front
Dictionary is not indexed by number
Back
True/False: A mutator method has no control over the way that a class's data attributes are modified.
Front
false
Back
True/False: An object is a stand-alone program but is used by programs that need its service.
Front
false
Back
Which function would you use to get the number of elements in a dictionary?
Front
len
Back
True/False: Programs that use tkinter do not always run reliably under IDLE.
Front
true
Back
What is another name for the mutator methods?
Front
setters
Back
When a method is called, what does Python make to reference the specific object on which the method is supposed to operate?
Front
self parameter
Back
Which section in the UML holds the list of the class's methods?
Front
third
Back
When there are several classes that have many common data attributes, it is better to write a(n) ________ to hold all the general data.
Front
superclass
Back
True/False: The pack method determines where a widget should be positioned.
Front
true
Back
What will be assigned to s_string after the execution of the following code?
special = '1357 Country Ln.'
s_string = special[4: ]
Front
'Country Ln.'
Back
When working with multiple sets of data, one would typically use a ________.
Front
nested list
Back
What is the value of the variable phones after the execution of the following code?
phones = {'John': '555555', 'Julie': '7777777'}
phones['John'] = '1234567'
Front
{'John': '1234567', 'Julie' : '7777777'}
Back
Which widget allows the user to select a value by moving a slider along a track?
Front
scale
Back
What will be assigned to the string variable pattern after the execution of the following code?
i = 3
pattern = 'z' (5 i)
Front
'zzzzzzzzzzzzzzz'
Back
Which section in the UML holds the list of the class's data attributes?
Front
second
Back
What does a subclass inherit from a superclass?
Front
attributes and methods
Back
True/False: A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
Front
false
Back
What method can be used to convert a tuple to a list?
Front
list
Back
Section 4
(20 cards)
True/False: New attributes and methods may be added to a subclass.
Front
true
Back
True/False: Each subclass has a method named __init__ that overrides the superclass's __init__.
Front
true
Back
True/False: A root widget's destroy method can be used as a callback function for a quit button.
Front
true
Back
The Toplevel widget is a container, like a ________, but displays in its own window.
Front
Frame
Back
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?
Front
accessor
Back
What is the correct structure for creating a dictionary of month names to be accessed by month numbers?
Front
{ 1 : 'January', 2 : 'February', 3 : 'March' }
Back
True/False: 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.
Front
true
Back
With what part of the computer does the user interact?
Front
user interface
Back
What is the combining of data and code in a single object known as?
Front
encapsulation
Back
What are the procedures that an object performs called?
Front
methods
Back
In the following line of code, what is the name of the base class?
class Male(Human):
Front
human
Back
Which method can you use to determine whether an object is an instance of a class?
Front
isinstance
Back
What are the items that appear on the graphical interface window called?
Front
widgets
Back
What is the special name given to the method that returns a string containing the object's state?
Front
__str__
Back
In Python, what module is used to create a GUI program?
Front
tkinter
Back
True/False: Object-oriented programming allows us to hide the object's data attributes from code that is outside the object.
Front
True
Back
The acronym GUI stands for
Front
Graphical User Interface
Back
Base classes are also called ________
Front
superclasses
Back
Which of the following is the correct syntax for defining a class dining which inherits from class furniture?
Front
class dining(furniture):
Back
What type of programming contains class definitions?