Data Science + Python Interview Answers – Divya
Edition
1. Difference between list, tuple, set
List: ordered, mutable. Tuple: ordered, immutable. Set: unordered, unique elements.
2. Mutable vs Immutable
Mutable: can change (list, dict). Immutable: cannot change (tuple, string).
3. List comprehension
Simplified syntax: [x*x for x in range(5)].
4. *args and **kwargs
*args: variable positional args. **kwargs: variable keyword args.
5. range vs xrange
xrange existed in Python2; range in Python3 behaves like lazy xrange.
6. Shallow vs deep copy
Shallow: references nested objects. Deep: copies everything recursively.
7. Modules & Packages
Module: Python file. Package: folder with __init__.py containing modules.
8. Python memory management
Uses private heap, garbage collector.
9. Decorator
Function that modifies another function's behavior.
10. Exception handling
try-except-finally used to handle errors.
11. Lambda
Anonymous inline function: lambda x: x+1.
12. File handling
open('file','r'), read(), write(), close().
13. GIL
Global Interpreter Lock allowing one thread execution at a time.
14. OOP principles
Encapsulation, Inheritance, Polymorphism, Abstraction.
15. Descriptive vs inferential statistics
Descriptive summarises data; inferential predicts population from sample.
16. Correlation vs covariance
Correlation is normalised covariance (range -1 to 1).
17. Mean/median/mode
Median is robust to outliers.
18. Variance/SD
Variance = spread; SD = sqrt(variance).
19. p-value
Probability of observing results assuming null hypothesis is true.
20. Hypothesis testing
Procedure to test assumptions about population.
21. Type I & II errors
Type I: false positive. Type II: false negative.
22. Supervised vs unsupervised
Labelled data vs unlabelled clustering.
23. Overfitting vs underfitting
Overfitting: memorises noise. Underfitting: too simple.
24. Avoiding overfitting
Regularisation, cross-validation, dropout.
25. Cross-validation
K-fold method to evaluate stability.
26. Feature scaling
Normalisation/standardisation for equal weight.
27. Regularisation
L1 (lasso) shrinks to zero; L2 (ridge) reduces magnitude.
28. Evaluation metrics
Accuracy, Precision, Recall, F1.
29. Confusion matrix
TP, TN, FP, FN summary table.
30. Bias-variance tradeoff
Balance between model simplicity vs flexibility.
31. Linear regression
Fits best line by minimising squared error.
32. Logistic regression
Classification using sigmoid.
33. Decision tree
Splits dataset based on features.
34. KNN
Classifies by nearest neighbours.
35. K-means
Unsupervised clustering algorithm.
36. PCA
Dimensionality reduction by variance.
37. Gradient descent
Optimisation algorithm reducing loss.
38. ML vs DL
DL uses neural networks; ML uses simpler algorithms.
39. Neural networks
Layers of interconnected neurons.
40. Activation functions
ReLU: fast; Sigmoid: binary; Tanh: centred.
41. Backpropagation
Algorithm to update weights.
42. Loss function
Measures prediction error.
43. Overfitting in NN
Too many parameters, solved with dropout.
44. CNNs
Used for image analysis.
45. Epoch/batch/iteration
Epoch: full dataset pass. Batch: subset. Iteration: one update.
46. Load dataset with pandas
df = pandas.read_csv().
47. NumPy broadcasting
Expands shapes for elementwise operations.
48. Matplotlib vs seaborn
Matplotlib: low-level. Seaborn: statistical plots.
49. Missing values check
[Link]().sum().
50. Handle missing data
Drop or impute.
51. Sklearn
ML algorithms, preprocessing, evaluation.
52. Handling missing values
Impute mean/median or remove.
53. Choose best model
Compare metrics + cross-validation.
54. Detect outliers
IQR, Z-score.
55. Fix imbalanced dataset
SMOTE, class weights.
56. Good train, bad test accuracy
Overfitting.
57. Model deployment
Using Flask/FastAPI, Docker.
58. AI in infrastructure
Predict failures, optimise planning.
59. Risk prediction models
Regression, classification.
60. Computer vision in infra
Crack detection, safety monitoring.
61. Predictive analytics
Estimate delays, costs.
62–66. Project explanation
Explain goal, data cleaning, challenges, model choice, improvements.
67. Why data science?
Interest in insights + problem solving.
68. Why Heyram Infrastructure?
Domain growth + real-world AI impact.
69. Internship expectation
Learning + practical exposure.
70. Stipend comfort
Yes, focusing on experience.
71. Strengths & weaknesses
Strength: analytical; Weakness: perfectionism.
72. 2-year vision
Skilled data scientist contributing to end-to-end projects.