EXAM QUESTIONS
Even though methods are similar to functions, briefly state what makes a method
different than a function - CORRECT ANSWER>>>>methods are associated with
an object as they call on an object
What is the purpose of the class' constructor? - CORRECT ANSWER>>>>to
define the way in which objects are created
What is the name of the constructor method when defining it in a class -
CORRECT ANSWER>>>>__init__
What do we need to do in order to create an instance of a class? - CORRECT
ANSWER>>>>use the name of the class and pass actual values for the necessary
state to create an object
What is the purpose of the self parameter? - CORRECT ANSWER>>>>to
represent the object you are intending to call the method on
What is the method name to convert an object to a string? - CORRECT
ANSWER>>>>__str__
What is == comparing? - CORRECT ANSWER>>>>if two objects are the same;
will only return true if the two objects are the same object
What does deep equality mean? - CORRECT ANSWER>>>>values are compared
rather than the memory addresses
What does shallow equality mean? - CORRECT ANSWER>>>>memory
addresses are used to compare objects
What are four characteristics a list inherits from its direct parent - CORRECT
ANSWER>>>>ordering of the underlying data, concatenation, repetition, and
indexing
What makes a Binary Gate differ from a Unary Gate type - CORRECT
ANSWER>>>>binary gate's have two lines of input while unary gate's have one
line of input
, two computing resources considered when doing analysis of an algorithm -
CORRECT ANSWER>>>>time and memory
what is the problem of using the computer to time various algorithms - CORRECT
ANSWER>>>>sometimes the performance of an algorithm depends on the exact
values of the data instead of problem size, so performance is characterized by best,
average, or worst case
State the relationship between O(n) and T(n) - CORRECT ANSWER>>>>O(n) is
the part of T(n) that increases the fastest as the value of n increases
What is happening when removing an element from the front of a list? -
CORRECT ANSWER>>>>all the other elements are shifted in the list on position
closer to the beginning of the list
what are the three laws of recursion - CORRECT ANSWER>>>>1. must have a
base case 2. must change its state and move toward the base case 3. must call itself,
recursively
mutable - CORRECT ANSWER>>>>lists, dictionaries
immutable - CORRECT ANSWER>>>>strings, tuples, integers
dictionaries - CORRECT ANSWER>>>>has a unique key that maps to a value;
keys must be immutable while values can be any type
methods - CORRECT ANSWER>>>>like functions but associated with an object
syntax error - CORRECT ANSWER>>>>error in a program that makes it
impossible to parse and therefore impossible to interpret
runtime error - CORRECT ANSWER>>>>error that does not occur until the
program has started to execute by that prevents the program from continuing
try/except order - CORRECT ANSWER>>>>except statements are checked top-
down and the first matching exception type block is executed
Test Driven Development (TDD) - CORRECT ANSWER>>>>1. write tests that
describe what the intended behavior of a unit of software should do 2. implement