Which type of tree would you use to implement an ordered map?

  • AVL Tree
  • Binary Search Tree (BST)
  • Heap
  • Red-Black Tree
To implement an ordered map, you would typically use a Binary Search Tree (BST). A BST ensures that elements are stored in sorted order, making it efficient for operations like search, insert, and delete in O(log n) time.

You are asked to create a new column in a DataFrame that is the sum of two other columns. How would you create this new column in Pandas?

  • df.create_column('new_column', df.column1 + df.column2)
  • df.new_column = df.column1 + df.column2
  • df['new_column'] = df['column1'] + df['column2']
  • df['new_column'] = df['column1'].add(df['column2'])
To create a new column in a Pandas DataFrame that is the sum of two existing columns, you would use the syntax df['new_column'] = df['column1'] + df['column2']. This operation will perform element-wise addition and create the new column.

You are asked to create a plot comparing the distribution of a variable across different categories, highlighting the median and interquartile range. Which Seaborn plot would you choose?

  • Box Plot
  • Line Plot
  • Swarm Plot
  • Violin Plot
To compare the distribution of a variable across categories while highlighting the median and interquartile range, a Violin Plot in Seaborn is a suitable choice. It combines a box plot with a kernel density estimation to provide a richer visualization of the data distribution.

Which Python library is specifically designed for creating static, interactive, and real-time graphs and plots?

  • Matplotlib
  • NumPy
  • Pandas
  • Seaborn
Matplotlib is specifically designed for creating static, interactive, and real-time graphs and plots in Python. It is a widely-used plotting library for data visualization.

Which Matplotlib function allows plotting data points in the form of a two-dimensional density plot?

  • contour()
  • heatmap()
  • hist2d()
  • scatter()
The heatmap() function in Matplotlib allows you to create a two-dimensional density plot. It is useful for visualizing the distribution and density of data points in a heatmap-like format.

Which method can be used to get the value for a given key from a dictionary, and if the key is not found, it returns a default value?

  • fetch()
  • get()
  • retrieve()
  • value()
The get() method of a dictionary allows you to retrieve the value associated with a given key. If the key is not found, it returns a default value, which can be specified as a second argument to get(). This is a useful way to avoid KeyError exceptions. The other options are not valid methods for this purpose.

Which method in Scikit-learn would you use to tune hyperparameters of a model?

  • fit()
  • gradient_boosting()
  • GridSearchCV
  • predict()
GridSearchCV is used in Scikit-learn for hyperparameter tuning. It performs an exhaustive search over specified hyperparameter values to find the best combination for the model.

Which method is commonly used to send data from a web form to a Python back-end?

  • FETCH
  • GET
  • POST
  • PUT
The common method used to send data from a web form to a Python back-end is POST. When a user submits a form, the data is sent to the server using the POST method, which allows for secure transmission of sensitive information. GET is used to retrieve data, while PUT and FETCH serve other purposes in web development.

Which of the following data structures is best suited for a First In First Out (FIFO) approach?

  • Binary Tree
  • Hash Table
  • Queue
  • Stack
A queue is a data structure that follows the First In First Out (FIFO) approach. It means that the first element added to the queue will be the first one to be removed. Queues are often used in scenarios like scheduling tasks or managing resources in a sequential manner.

Which of the following sorting algorithms is most efficient for small-sized data sets?

  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
Insertion sort is the most efficient sorting algorithm for small-sized data sets. It has a simple implementation and performs well when the number of elements is small. Other sorting algorithms like Quick Sort and Merge Sort are more efficient for larger data sets.