“defaultdict” forces a dictionary to only accept keys that are of the types specified when you created the “defaultdict” (such as string or integers).// CORRECT
Q15.What is the correct syntax for defining a class called “Game”, if it inherits from a parent class called “LogicGame”?
class Game(LogicGame): pass // CORRECT
Q16.What is the purpose of the “self” keyword when defining or calling instance methods?
self refers to the instance whose method was called // CORRECT
Q17.Which of these is NOT a characteristic of namedtuples?
No import is needed to use namedtuples because they are available in the standard library // CORRECT
Q18.What is an instance method?
Instance methods can modify the state of an instance or the state of its parent class //CORRECT
Q19.Which choice is the most syntactically correct example of the conditional branching?
num_people = 5
if num_people > 10;
print(“There is a lot of people in the pool.”)
if num_people > 4;
print(“There are some people in the pool.”)
if num_people > 0;
print(“There are a few people in the pool.”)
print(“There is no one in the pool.”)
num_people = 5 // CORRECT
Q20.Which statement does NOT describe the object-oriented programming concept of encapsulation?
It only allows the data to be changed by methods // CORRECT
Q21.What is the purpose of an if / else statement?
An if / else statement executes one chunk of code if a condition it true, but a different chunk of code if the condition is false // CORRECT
Q22.What buit – in Python data type is commonly used to represent a queue?
list // CORRECT
Q23.What is the correct syntax for instantiating a new object of the type Game?
my_game = (Game) // CORRECT
Q24.What does the built-in map() function do?
It applies a function to each item in an iterable and returns the value of that function. // CORRECT
Q25.If you don’t explicitly return a value from a function, what happens?
If the return keyword is absent, the function will return None. // CORRECT
Q26.What is the purpose of the pass statement in Python?
It is a null operation used mainly as a placeholder in functions, classes, etc. // CORRECT
Q27.What is the term used to describe items that may be passed into a function?
arguments // CORRECT
Q28.Which collection type is used to associate values with unique keys?
dictionary // CORRECT
Q29.When does a for loop stop iterating?
when it encounters an if / else statement that contains a break keyword // CORRECT
Q30.Assuming the node is in a singly linked list, what is the runtime complexity of searching for a specific node within a singly linked list?
The runtime is O(n) because in the worst case, the node you are searching for is the last node, and every node in the linked list must be visited.// CORRECT
Q31.Given the following three lists, how would you create a new list that matches the desired output printed below?
fruits = [‘apples’, ‘oranges’, ‘bananas’]
quantities = [5, 3, 4]
prices = [1.50, 2.25, 0.89]