Python Chapter 5
b.parameter
A(n) ____ is the name used in the function definition for an argument that is passed to the function when it is called. a.variable b.parameter c.class d.object
T
Although a list's elements are always ordered by position, it is possible to impose a natural ordering on them as well.
F
An Identity function usually tests its argument for the presence or absence of some property.
T
Anytime you foresee using a list whose structure will not change, you can, and should, use a tuple instead.
T
Each item in a list has a unique index that specifies its position.
d.tuple
A(n) ____ is a type of sequence that resembles a list, except that, unlike a list, it is immutable. a.index b.class c.string d.tuple
T
When replacing an element in a list, the subscript is used to reference the target of the assignment statement, which is not the list but an element's position within it.
F
When used with a single list argument, the function maximum returns the largest value contained therein.
T
You add a new key/value pair to a dictionary by using the subscript operator [].
d.dictionary
28. A ____ organizes data values by association with other data values rather than by sequential position. a.list b.string c.data structure d.dictionary
b.items
29. A list is a sequence of data values called ____. a.indexes b.items c.iterators d.components
a.len(L)
31. ____ returns the number of elements in the list. a.len(L) b.siz(L) c.length(L) d.size(L)
a.pop
35. The L.____() method of the list type removes and returns the element at the end of the list. a.pop b.remove c.get d.append
a.pop
36. The L.____(index) method of the list type removes and returns the element at index. a.pop b.remove c.get d.append
b.mutators
37. Mutable objects have some methods devoted entirely to modifying the internal state of the object. Such methods are called ____. a.accessors b.mutators c.modifiers d.procedures
c.items()
50. You can use the dictionary method ____ to access a list of the dictionary's entries. a.elements() b.entries() c.items() d.list()
F
A Python dictionary is written as a sequence of key/value pairs separated by commas. These pairs are sometimes called indexes.
a.list
A ____ allows the programmer to manipulate a sequence of data values of any types. a.list b.string c.data structure d.dictionary
d.dictionary
A ____ organizes information by association. a.string b.tuple c.list d.dictionary
T
A function can be defined in a Python shell, but it is more convenient to define it in an IDLE window, where it can be saved to a file.
F
A list is a sequence of data values called indexes.
F
A list is immutable.
T
A lookup table is a type of dictionary.
c.None
If a function contains no return statement, Python transfers control to the caller after the last statement in the function's body is executed, and the special value ____ is automatically returned. a.'\n' b.EOF c.None d.Null
T
If pop is used with just one argument and this key is absent from the dictionary, Python raises an error.
a. has_key
If the existence of a key is uncertain, the programmer can test for it using the dictionary method ____. a. has_key b. haskey c. hasKey d. has-key
d.dictionary
In Python, a ____ associates a set of keys with data values. a.string b.tuple c.list d.dictionary
F
In a dictionary, a -> separates a key and its value.
a.tables
In computer science, data structures organized by association are sometimes called ____. a.tables b.lists c.stacks d.queues
F
In scripts that include the definitions of several cooperating functions, it is often useful to define a special function named init that serves as the entry point for the script.
T
Lists of integers can be built using the range function.
b.is
Python's ____ operator can be used to test for object identity. a.in b.is c.equals d.refers
F
The == operator returns True if the variables are aliases for the same object. Unfortunately, == returns False if the contents of two different objects are the same.
c.extend
The L.____(aList) method of the list type adds the elements of L to the end of aList. a.join b.concatenate c.extend d.append
c.median
The ____ is the value which is less than half the numbers in the set and greater than the other half. a.variance b.mean c.median d.mode
d.append
The ____ method of the list type adds an element to the end of the list. a.addToEnd b.addLast c.atEnd d.append
T
The definition of the main function and the other function definitions can appear in no particular order in the script, as long as main is called at the very end of the script.
F
The index of the first item in a list is 1.
F
The index of the last item in a list is the length of the list.
F
The is operator has no way of distinguishing between object identity and structural equivalence.
F
The list method ascending mutates a list by arranging its elements in ascending order.
T
The main function usually expects no arguments and returns no value.
F
The median of a list of values is the value that occurs most frequently.
c.pop
To delete an entry from a dictionary, one removes its key using the method ____. a.get b.delete c.pop d.remove
T
To prevent aliasing, a new object can be created and the contents of the original can be copied to it.
a.clear()
You can use the dictionary method ____ to remove all the keys in the dictionary. a.clear() b.reset() c.remove() d.zero()
F
You cannot use the equality operator to compare two integer lists.
a.()
You indicate a tuple literal in Python by enclosing its elements in ____. a.() b.[] c.<> d.{}
b.{}
____ is an example of an empty dictionary. a.[] b.{} c.() d.<>
c.[2:4]
____ is not a valid list in Python. a.[] b.['apples','oranges'] c.[2:4] d.[[5, 9], [541, 78]]
b.0 through upper - 1
range(<upper>) returns a list containing the integers in the range ____. a.0 through upper b.0 through upper - 1 c.1 through upper d.1 through upper - 1