Skip to content
DK » Blog » Python Skill Assessment Quizzes – Part 2

Python Skill Assessment Quizzes – Part 2

Suppose a Game class inherits from two parent classes: BoardGame and LogicGame. Which statement is true about the methods of an object instantiated from the Game class?

  • When instantiating an object, the object doesn’t inherit any of the parent class’s methods.
  • When instantiating an object, the object will inherit the methods of whichever parent class has more methods.
  • When instantiating an object, the programmer must specify which parent class to inherit methods from.
  • An instance of the Game class will inherit whatever methods the BoardGame and LogicGame classes have.

What symbol(s) do you use to assess equality between two elements?

  • &&
  • =
  • ==
  • ||

What value would be returned by this check for equality?

5 != 6

  • yes
  • False
  • True
  • None

What is meant by the phrase “space complexity”?

  • How many microprocessors it would take to run your code in less than one second
  • How many lines of code are in your code file
  • The amount of space taken up in memory as a function of the input size
  • How many copies of the code file could fit in 1 GB of memory

What statement about the class methods is true?

  • A class method is a regular function that belongs to a class, but it must return None.
  • A class method can modify the state of the class, but they can’t directly modify the state of an instance that inherits from that class.
  • A class method is similar to a regular function, but a class method doesn’t take any arguments.
  • A class method hold all of the data for a particular class.

What is the proper way to define a function?

  • def getMaxNum(list_of_nums): # body of function goes here
  • func get_max_num(list_of_nums): # body of function goes here
  • func getMaxNum(list_of_nums): # body of function goes here
  • def get_max_num(list_of_nums): # body of function goes here

Describe the functionality of a deque.

  • A deque adds items to one side and remove items from the other side.
  • A deque adds items to either or both sides, but only removes items from the top.
  • A deque adds items at either or both ends, and remove items at either or both ends.
  • A deque adds items only to the top, but remove from either or both sides.

Why would you use a decorator?

  • A decorator is similar to a class and should be used if you are doing functional programming instead of object oriented programming.
  • A decorator is a visual indicator to someone reading your code that a portion of your code is critical and should not be changed.
  • You use the decorator to alter the functionality of a function without having to modify the functions code.
  • An import statement is preceded by a decorator, python knows to import the most recent version of whatever package or library is being imported.

What would happen if you did not alter the state of the element that an algorithm is operating on recursively?

  • You do not have to alter the state of the element the algorithm is recursing on.
  • You would eventually get a KeyError when the recursive portion of the code ran out of items to recurse on.
  • You would get a RuntimeError: maximum recursion depth exceeded.
  • The function using recursion would return None.

What is the runtime complexity of adding an item to a stack and removing an item from a stack?

  • Add items to a stack in O(1) time and remove items from a stack on O(n) time.
  • Add items to a stack in O(1) time and remove items from a stack in O(1) time.
  • Add items to a stack in O(n) time and remove items from a stack on O(1) time.
  • Add items to a stack in O(n) time and remove items from a stack on O(n) time.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.