Which Python data structure is suitable for storing multiple data types and allows duplicate elements?
- Dictionary
- List
- Set
- Tuple
In Python, a list is a versatile data structure that can store multiple data types and allows duplicate elements. Lists are ordered and mutable, making them suitable for a wide range of use cases.
Which Python built-in function will you use to sort a list of numbers in ascending order?
- arrange()
- order()
- sort()
- sorted()
To sort a list of numbers in ascending order, you should use the sorted() function. The sort() method is used for in-place sorting, whereas sorted() returns a new sorted list, leaving the original list unchanged.
Which Pandas function is used to read a CSV file into a DataFrame?
- read_csv()
- read_excel()
- read_json()
- read_sql()
The correct function to read a CSV file into a DataFrame in Pandas is read_csv(). It's used to load data from a CSV (Comma-Separated Values) file into a tabular data structure.
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.
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 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 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 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 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 library would you primarily use for implementing linear regression in Python?
- Matplotlib
- NumPy
- Pandas
- Scikit-learn
Scikit-learn is a powerful library in Python for machine learning, including linear regression. While NumPy, Pandas, and Matplotlib are essential for data manipulation and visualization, Scikit-learn provides tools for regression tasks, making it the primary choice for linear regression.
Which keyword is used to import a module in Python?
- import
- include
- module
- require
In Python, you use the import keyword to import modules. Modules are Python files containing reusable code and data.
Which keyword is used to create a class in Python?
- class
- cls
- def
- object
In Python, the keyword used to create a class is class. Classes are used to define new data types and their behaviors.