How can you annotate a specific point on a plot in Matplotlib?

  • Add a comment with # symbol
  • Click directly on the point
  • Place a text box with plt.text()
  • Use annotate() function
To annotate a specific point on a plot in Matplotlib, you can use the plt.text() function. This function allows you to add custom text at specified coordinates on the plot, making it useful for labeling data points or adding additional information.

How can you avoid hardcoding the URL in Django templates when using the anchor tag?

  • Use JavaScript to dynamically set the URL
  • Use the {% href 'url_name' %} template tag
  • Use the {% url 'url_name' %} template tag
  • Use the href attribute directly with the hardcoded URL
To avoid hardcoding URLs in Django templates, you can use the {% url 'url_name' %} template tag, which dynamically generates URLs based on the URL patterns defined in your Django project. This promotes maintainability and helps prevent broken links when URLs change.

How can you call a function named my_function defined in a module named my_module?

  • call(my_module.my_function)
  • my_function(my_module)
  • my_module.call_my_function()
  • my_module.my_function()
To call a function defined in a module, you use the module name followed by a dot and then the function name. In this case, it would be my_module.my_function().

How can you call a method of the parent class from within a method of a child class?

  • By creating an instance of the parent class
  • By directly calling the parent method
  • Using the parent_method() syntax
  • Using the super() function
You can call a method of the parent class from within a method of the child class using the super() function followed by the method you want to call. This allows you to access and execute the parent class's method.

How can you change the order of method resolution in multiple inheritance?

  • By changing the order of base classes in the class definition
  • By using the @method_resolution decorator
  • Using the C3 Linearization algorithm (C3 superclass linearization)
  • Using the super() function
You can change the order of method resolution in multiple inheritance in Python by using the C3 Linearization algorithm (C3 superclass linearization). This algorithm calculates the order in which base classes are considered when looking up methods. The super() function is used to call methods in the method resolution order, but it doesn't change the order itself. Changing the order of base classes in the class definition directly affects method resolution but is discouraged. There is no standard @method_resolution decorator in Python.

A ____ tree is a tree in which each node has at most two children, which are referred to as the left child and the right child.

  • Binary
  • Octal
  • Quad
  • Ternary
A Binary Tree is a tree data structure where each node has at most two children, a left child and a right child. This data structure is commonly used in computer science and is fundamental to many algorithms and data structures.

A decorator in Python is a design pattern used to add new functionality to an object without altering its ____.

  • attributes
  • class
  • methods
  • structure
In Python, decorators are typically used to add new functionality to methods of a class without changing the method's name or signature. This is commonly used for tasks like logging, authorization, and caching.

A ____ algorithm guarantees to run in the same time (or space) for any input of the same size.

  • Deterministic
  • In-Place
  • Non-Deterministic
  • Stable
A Deterministic algorithm guarantees to run in the same time (or space) for any input of the same size. It is predictable and has consistent performance.

A ____ in Python is a collection of key-value pairs, where the keys must be immutable.

  • Dictionary
  • List
  • Set
  • Tuple
In Python, a dictionary is a collection of key-value pairs, where the keys must be immutable (and usually unique). Tuples are immutable, making them suitable for use as dictionary keys.

A ____ is a data structure that stores elements in a linear sequence but allows additions and removals only at the start.

  • Array
  • Linked List
  • Queue
  • Stack
A Stack is a data structure that follows the Last-In-First-Out (LIFO) principle, meaning the last element added is the first to be removed. It allows additions and removals at the start, making it suitable for managing function calls, undo functionality, and more.