Python Final Exam Study Guide
This operator performs division, but instead of returning the quotient it returns the remainder.
%
This operator can be used to find the difference of two sets.
-
This operator performs integer division.
/ /
Which of the following would you use if an element is to be removed from a specific index?
A del statement
A variable used to keep a running total is called a(n).
Accumulator
Which of the following can be thought of as a self-contained unit that consists of data attributes and the methods that operate on the data attributes?
An object
When a file is opened in this mode, data will be written at the end of the file's existing contents.
Append mode
A _ is a piece of data that is sent into a function.
Argument
A(n) __________ is any piece of data that is passed into a function when the function is called.
Argument
A _ makes a variable reference a value in the computer's memory.
Assignment statement
By doing this, you can hide a class's attribute from code outside the class.
Begin the attribute's name with two underscores
A set of statements that belong together as a group and contribute to the function definition is known as a.
Block
This is a small "holding section" in memory that many systems write data to, before writing the data to a file.
Buffer
If a class has a method named __str__, which of these is a way to call the method? By passing an instance of the class to the built in str function
By passing an instance of the class to the built in str function
This function in the random module returns a random element from a list.
Choice
A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is.
Code reuse
What type of loop structure repeats the code based on the value of Boolean expression?
Condition Controlled loop
A(n) __________ structure is a logical design that controls the order in which a set of statements execute.
Control Structure
What type of loop structure repeats the code a specific number of times?
Count Controlled loop
What will be assigned to the variable s_string after the following code executes? special = '1357 Country Ln.' s_string = special[5:]
Country Ln.
A _ is a component of a class that references data.
Data attribute
A _ structure can execute a set of statements only under certain circumstances.
Decision
This marks the location of the next item that will be read from a file.
Delimiter
When working with this type of file, you can jump directly to any piece of data in the file without reading the data that comes before.
Direct access
This set method removes an element but does not raise an exception if the element is not found.
Discard
The decision structure that has two possible paths of execution is known as __.
Dual Alternative
What are the data items in a list called?
Elements
Combining data and code in a single object is known as.
Encapsulation
A program can be made only of one type of control structure. You cannot combine structures.
False
A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.
False
The following statement creates an empty set. Myset = ().
False
You can write any program using only sequence structures.
False
A single piece of data within a record is called a.
Field
This string method returns the lowest index in the string where a specified substring is found.
Find
A _ is a Boolean variable that signals when some condition exists in the program.
Flag
Which of the following functions returns the largest integer that is less than or equal to its argument?
Floor
A group of statement that exists within a program for the purpose of performing a specific task is a.
Function
Accessor methods are also known as.
Getters
A __________ variable is accessible to all the functions in a program file.
Global
A _ is a diagram that gives a visual representation of the relationships between functions in a program.
Hierarchy chart
This is a design tool that describes the input, processing, and output of a function.
IPO chart
In object-oriented programming, one of first tasks of the programmer is to.
Identify classes needed
__________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.
Input
Which method can be used to place an item at a specific index in a list?
Insert
An object is an.
Instance
Which attributes belong to a specific instance of a class?
Instance
A _ error does not prevent the program from running but causes it to produce incorrect results.
Logic
And, or, and not are _ operators.
Logical
This string method returns a copy of the string with all leading whitespace characters removed.
Lstrip
The procedures that an object performs are called.
Methods
The _ operator takes a Boolean expression as its operand and reverses its logical value.
Not
Which logical operators perform short-circuit evaluation?
Or, and
A file that data is written to is known as a.
Output file
A(n) __________ is a variable that receives an argument that is passed into a function.
Parameter
Which method would you use to get the value associated with a specific key and remove that key-value pair from the dictionary?
Pop
The first operation is called the __________ and its purpose is to get the first input value that will be tested by the validation loop.
Priming Read
The _ programming practice is centered on creating functions that are separate from the data they work on.
Procedural
A(n) __________ access file is also known as a direct access file.
Random
Which type of file access jumps directly to a piece of data in the file without having to read all the data that comes before it?
Random
Which method will return an empty string when it has attempted to read beyond the end of a file?
Readline
The symbols >, <, and == are all _ operators.
Relational
This set method removes an element and raises an exception if the element is not found.
Remove
This function in the random module returns multiple, nonduplicated random elements from a list.
Sample
A _ is the part of a program in which a variable may be accessed.
Scope
Which section in the UML holds the list of the class's data attributes?
Second section
Which type of file access jumps directly to a piece of data in the file without having to read all the data that comes before it?
Sequential
When working with this type of file, you access its data from the beginning of the file to the end of the file.
Sequential access
Mutator methods are also known as.
Setters
A _ structure provides one alternative path of execution.
Single alternative decision
A _ is a single function that the program must perform in order to satisfy the customer.
Software requirement
This string method returns a copy of the string with all leading and trailing whitespace characters removed.
Strip
Which of the following describes what happens when a piece of data is written to a file?
The data is copied from a variable in RAM to a file.
Which of the following does not apply to sets?
The elements are pairs.
Which of the following is associated with a specific file and provides a way for the program to work with that file?
The file object
Which section in the UML holds the list of the class's methods?
Third section
A design technique that programmers use to break down an algorithm into functions is known as.
Top-down design
What is an advantage of using a tuple rather than a list?
Tuples are faster
This standard library function returns floating-point number within a specified range of values.
Uniform
Which of the following statements creates a tuple?
Values = (1, )
A _ is a name that references a value in the computer's memory.
Variable
This operator can be used to find the symmetric difference of two sets.
^
The _ method is automatically called when an object is created.
__init__
What is the special name given to the method that returns a string containing an object's state?
__str__
The _ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value.
get()
Which of the following is the correct way to open a file named users.txt in 'r' mode?
infile = open('users.txt', 'r')
Which method would you use to get all the elements in a dictionary returned as a list of tuples?
items()
The _ method returns a randomly selected key-value pair from a dictionary.
popitem()
This string method returns true if a string contains only alphabetic characters and is at least one character in length.
the isalpha method
Which statement can be used to handle some of the runtime errors in a program?
try/except statement
Which method can be used to add a group of elements to a set?
update()
Which of the following will create an object, worker_joey, of the Worker class?
worker_joey = Worker()
What values will d2 contain after the following code executes? d = {1: 10, 2: 20, 3: 30} d2 = {k:v for k,v in d.items()}.
{1:10, 2:20, 3:30}
This operator can be used to find the union of two sets.
|