The ____ keyword in Python is used to define conditions under which a block of code will be executed.

  • if
  • switch
  • try
  • while
In Python, the 'if' keyword is used to define conditions for conditional execution of code blocks. Code within an 'if' block is executed only if the specified condition evaluates to true.

The ____ method in a metaclass is called when a new object is created from a class.

  • __del__
  • __init__
  • __new__
  • __str__
The __new__ method in a metaclass is called when a new object is created from a class. This method is responsible for creating and returning a new instance of the class.

The ____ method in generator objects is used to resume the generator and send a value back to it.

  • next
  • resume
  • send
  • yield
The send method is used to resume a generator and send a value back to it. This is commonly used for implementing two-way communication with a generator.

The ____ method in Pandas DataFrame is used to rearrange the order of the DataFrame's columns.

  • rearrange()
  • reindex()
  • reorder_columns()
  • sort()
In Pandas DataFrame, the reorder_columns() method is used to rearrange the order of the DataFrame's columns. This method allows you to specify the new order of columns using a list or other methods like loc.

The ____ method in Pandas is used to drop specified labels from rows or columns.

  • delete
  • discard
  • drop
  • remove
In Pandas, the drop method is used to drop specified labels (rows or columns) from a DataFrame. This method provides options to control whether the operation should be performed in place or return a new DataFrame.

You need to build a RESTful API with Django that should include filtering, sorting, and pagination functionalities. How would you implement these functionalities efficiently?

  • Manually implement filtering, sorting, and pagination logic in your Django views.
  • Use Django REST framework, which provides built-in features for filtering, sorting, and pagination.
  • Use JavaScript on the client-side for filtering, sorting, and pagination.
  • Use plain Django views without any additional packages.
Django REST framework simplifies the process of building RESTful APIs and includes built-in support for filtering, sorting, and pagination. Manually implementing these features (Option 2) can be error-prone and time-consuming. Option 3 lacks the required features. Option 4 suggests client-side implementation, which may not be efficient or secure.

You need to create a data structure to hold a collection of elements, where each element has a unique key associated with it. Which Python data structure would you use?

  • Dictionary
  • List
  • Set
  • Tuple
In Python, a dictionary is the appropriate data structure for storing a collection of elements with unique keys. It allows efficient key-based access to elements, making it suitable for tasks like creating a mapping between keys and values.

You need to create a singleton class, i.e., a class that allows only one instance. Which Python concept can help you ensure that there is only one instance of the class in the system?

  • Abstract Classes
  • Decorators
  • Private Methods
  • Singleton Pattern
The Singleton Pattern is used to ensure that a class has only one instance and provides a way to access that instance from any point in the application. It typically involves creating a private constructor and a static method to retrieve the single instance.

You need to create a visualization that represents the correlation between all numerical variables in a dataset. Which kind of plot would you use in Seaborn?

  • Bar Chart
  • Box Plot
  • Heatmap
  • Scatter Plot
To visualize the correlation between numerical variables, a heatmap is typically used in Seaborn. It provides a color-coded matrix where each cell represents the correlation coefficient between two variables, making it easy to identify patterns and relationships.

You need to design a data structure that allows for retrieval of the most recently added element and removal of the least recently added element. How would you design such a data structure?

  • Linked List
  • Priority Queue
  • Queue
  • Stack
To achieve this behavior, you can use a Priority Queue. It maintains elements in a way that allows efficient retrieval of both the most recently added element and the removal of the least recently added element.