Filters
Question type

Study Flashcards

The design and implementation of a collection class consists of two steps. What is the first step?


A) document the class using docstrings
B) choose an appropriate data structure
C) write the code for the defined methods
D) test the method using sample data

E) All of the above
F) A) and C)

Correct Answer

verifed

verified

The code for the add method for the ArrayBag class is shown below. What is the missing code? Def add(self, item) : Self.items[len(self) ] = item < missing code >


A) self.items +=1
B) self = self + 1
C) self.size += 1
D) self.len = self.items

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

What is the last step in the remove function in the ArrayBag class?


A) check the precondition
B) shift items to the right
C) resize the array
D) search for the target item index

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

When Python sees a for loop on an iterable object, it runs that object's __add__ method.

A) True
B) False

Correct Answer

verifed

verified

What is found in the body of the method code that is used to document the method?


A) mutators
B) parameters
C) docstring
D) arguments

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

When Python sees the in operator used with a collection, it runs the __contains__ method in the collection's class.

A) True
B) False

Correct Answer

verifed

verified

The logical size of an array-based bag will always be the same as the array's capacity.

A) True
B) False

Correct Answer

verifed

verified

When the LinkedBag structure is not empty, self.items refers to the last node in the linked structure.

A) True
B) False

Correct Answer

verifed

verified

What is the name of the method that performs the constructor operation for a class?


A) __eq__
B) __iter__
C) __add__
D) __init__

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

Which Python function allows you to obtain information about a module, data type, method, or function?


A) help
B) list
C) doc
D) info

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Showing 41 - 50 of 50

Related Exams

Show Answer