Data Science MCQ Questions And Answers

41. What is the NumPy library in data science?

  1. A Python library for natural language processing and text analysis
  2. A fundamental Python library for scientific computing that provides efficient multi-dimensional array operations, mathematical functions, and linear algebra capabilities
  3. A Python library for creating web applications that visualize data in real time
  4. A database connectivity library that allows Python to query SQL databases

Answer : B
Explanation: NumPy (Numerical Python) is the foundational library for scientific computing in Python. Its core data structure — the ndarray (N-dimensional array) — enables vectorized operations that are dramatically faster than Python lists (10-100x) because they use contiguous memory and C-compiled code. Key features: array creation and manipulation, mathematical functions (mean, std, sqrt, etc.), linear algebra (matrix operations, dot products), random number generation, and broadcasting (performing operations on arrays of different shapes). NumPy is the backbone of almost all scientific Python libraries including Pandas, Scikit-learn, TensorFlow, and SciPy.

42. What is Matplotlib used for in data science?

  1. A Python library for matrix operations and linear algebra computations
  2. A Python data visualization library for creating static, animated, and interactive plots including line charts, bar charts, scatter plots, histograms, and heatmaps
  3. A machine learning library for building classification and regression models
  4. A data ingestion library for connecting Python to various data sources

Answer : B
Explanation: Matplotlib is Python’s most widely used data visualization library, providing a MATLAB-like interface for creating publication-quality plots. Key plot types: plt.plot() (line charts), plt.bar() (bar charts), plt.scatter() (scatter plots), plt.hist() (histograms), plt.boxplot() (box plots), plt.imshow() (image display). Seaborn is built on top of Matplotlib and provides higher-level statistical visualizations with more attractive defaults. Plotly provides interactive visualizations. Data visualization is a critical skill in data science — it enables EDA, communicates findings to stakeholders, and helps diagnose model issues through learning curves and confusion matrices.

43. What is Scikit-learn in data science?

  1. A deep learning framework developed by Google for building neural networks
  2. A Python machine learning library that provides simple and efficient tools for data mining and analysis, including classification, regression, clustering, dimensionality reduction, and model evaluation
  3. A data visualization library that creates interactive dashboards for data scientists
  4. A database management library for storing and querying machine learning model outputs

Answer : B
Explanation: Scikit-learn (sklearn) is the most popular Python library for traditional machine learning. It provides a consistent API for: Classification (Logistic Regression, SVM, Random Forest, Decision Trees), Regression (Linear Regression, Ridge, Lasso), Clustering (K-Means, DBSCAN), Dimensionality Reduction (PCA, t-SNE), Model Selection (cross_val_score, GridSearchCV), Preprocessing (StandardScaler, LabelEncoder, train_test_split), and Evaluation metrics (accuracy_score, confusion_matrix, roc_auc_score). Its consistent fit()/predict()/transform() API makes switching between algorithms easy. It is the go-to library for ML prototyping in data science interviews.

44. What is the difference between supervised and unsupervised learning in data science?

  1. Supervised learning is faster; unsupervised learning is more accurate for all problems
  2. Supervised learning trains on labeled data to predict outputs for new inputs; unsupervised learning finds hidden patterns and structure in unlabeled data without predefined target outputs
  3. Supervised learning is used only for regression; unsupervised learning is used only for classification
  4. Unsupervised learning requires more labeled training data than supervised learning

Answer : B
Explanation: Supervised Learning: the training dataset contains input-output pairs (labels). The model learns to map inputs to outputs. Examples: classification (email spam/not spam, disease/no disease) and regression (predicting house prices, stock values). Unsupervised Learning: the training dataset has no labels. The model finds hidden structure, patterns, or groupings. Examples: clustering (customer segmentation with K-Means), dimensionality reduction (PCA for visualization), and association rule mining. Semi-supervised learning uses a small amount of labeled data with a large amount of unlabeled data — a practical solution when labeling is expensive.

45. What is linear regression in data science?

  1. A classification algorithm that draws a line to separate two classes of data points
  2. A supervised learning algorithm that models the linear relationship between a dependent variable and one or more independent variables to predict continuous numerical output
  3. A data preprocessing technique that normalizes data to a linear scale
  4. An unsupervised learning technique that groups data into linear clusters

Answer : B
Explanation: Linear Regression models the relationship between a dependent variable (y) and independent variable(s) (x) as a linear equation: y = β₀ + β₁x₁ + β₂x₂ + … + ε. Simple Linear Regression uses one predictor; Multiple Linear Regression uses multiple predictors. The model is trained by minimizing the sum of squared residuals (Ordinary Least Squares). Assumptions: linearity, independence, homoscedasticity, and normality of residuals. Model evaluation uses R² (coefficient of determination), RMSE, and MAE. Linear regression is the most fundamental predictive modeling technique and a must-know for every data science interview.

46. What is logistic regression used for in data science?

  1. Predicting continuous numerical outcomes using a logistic curve
  2. A classification algorithm that predicts the probability of a binary or multi-class outcome using the logistic (sigmoid) function, outputting values between 0 and 1
  3. A regression technique specifically designed for predicting logarithmic relationships
  4. An unsupervised technique for grouping data using logistic distance metrics

Answer : B
Explanation: Despite its name, Logistic Regression is a classification algorithm, not regression. It predicts the probability that an instance belongs to a class using the sigmoid function: P(y=1) = 1/(1+e^(-z)). If P > 0.5, the instance is classified as class 1; otherwise class 0. It is used for: spam detection, disease prediction (diabetes, cancer), credit default prediction, and customer churn. Extensions include Multinomial Logistic Regression (for more than 2 classes) and Ordinal Logistic Regression. Logistic regression is interpretable, fast, and the standard baseline for binary classification problems in data science.

47. What is the bias-variance tradeoff in data science?

  1. A tradeoff between the computing time of a model and its storage requirements
  2. The fundamental tension in ML where reducing bias (model error from wrong assumptions) tends to increase variance (sensitivity to training data fluctuations) and vice versa — the goal is finding the optimal balance
  3. The tradeoff between the number of biased features used and the variance of predictions
  4. A tradeoff between the learning rate of gradient descent and the model’s variance

Answer : B
Explanation: The Bias-Variance Tradeoff is a central concept in ML model generalization. Bias: error from incorrect assumptions in the learning algorithm — a high-bias model is too simple (underfitting), performing poorly on both training and test data. Variance: error from sensitivity to small fluctuations in training data — a high-variance model memorizes training data (overfitting), performing well on training but poorly on test data. Total Error = Bias² + Variance + Irreducible Noise. The goal is finding the “sweet spot” of model complexity that minimizes total error on new data. Regularization, cross-validation, and ensemble methods help manage this tradeoff.

48. What is cross-validation in data science and why is it used?

  1. A technique for validating data entries across multiple database tables
  2. A model evaluation technique that splits data into multiple train-test folds to assess how well a model generalizes to new, unseen data and reduce overfitting
  3. A method for cross-checking the accuracy of two different models on the same dataset
  4. A validation technique used specifically to check if training data is balanced across classes

Answer : B
Explanation: Cross-validation provides a more reliable estimate of model performance than a single train-test split. K-Fold Cross-Validation (most common): the dataset is divided into k equal folds; the model trains on k-1 folds and tests on 1 fold, repeated k times (typically k=5 or k=10). The final score is the average across all k iterations. Stratified K-Fold maintains class proportions in each fold for imbalanced datasets. Leave-One-Out CV (LOOCV) uses n-1 samples for training and 1 for testing, repeated n times. Cross-validation helps detect overfitting and enables fair hyperparameter tuning.

49. What is the purpose of feature scaling in data science?

  1. To scale the number of features used in a model to match the training dataset size
  2. To normalize or standardize numerical feature values so they are on a comparable scale, preventing features with larger magnitudes from dominating distance-based or gradient-based algorithms
  3. To scale a model’s output predictions to match the expected range of target values
  4. A technique for reducing the number of features by scaling them down to a smaller subset

Answer : B
Explanation: Feature Scaling ensures all features contribute equally to model training. Without scaling, features with larger values (e.g., salary: $50,000) dominate features with smaller values (e.g., age: 30), misleading distance-based algorithms (KNN, SVM, K-Means) and slowing gradient descent. Two main methods: Min-Max Normalization (scales to [0,1]): x_scaled = (x – min)/(max – min). Standardization/Z-score (zero mean, unit variance): x_scaled = (x – μ)/σ. Tree-based algorithms (Decision Trees, Random Forest) do not require feature scaling. Linear regression, logistic regression, SVM, KNN, and neural networks do benefit significantly from scaling.

50. What is the difference between a Pandas Series and a DataFrame?

  1. A Series can store multiple data types; a DataFrame stores only numerical values
  2. A Series is a one-dimensional labeled array that can hold any data type; a DataFrame is a two-dimensional labeled data structure with rows and columns, like a table
  3. A DataFrame is a collection of NumPy arrays; a Series is a single Python list
  4. Series and DataFrame are identical — they are interchangeable terms for the same object

Answer : B
Explanation: A Pandas Series is a one-dimensional array-like object with an index (label) for each element — like a single column of a spreadsheet. It can hold any data type (int, float, str, etc.). A DataFrame is a two-dimensional table with named columns and a row index — each column is a Series. You can think of a DataFrame as a dictionary of Series objects sharing the same index. Key operations: creating from a dict or list (pd.DataFrame(), pd.Series()), accessing columns (df[‘col’]), filtering rows (df[df[‘col’] > value]), and applying functions (df.apply()). Both are at the heart of all Pandas data manipulation.