Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🚀 Week 9 – Deep Learning, Deploy & Career  ·  Day 55

Day 55: Data Science Interview Questions

⏱ 3 hours📶 Career🎯 100% self-study
Day 55 / 60

✅ Today you will learn

  • Know the interview rounds
  • Revise SQL, Python, statistics and ML answers
  • Solve live coding problems step by step
  • Handle case and product questions
  • Follow a 7-day revision plan

🏢 In the real world

Most data interviews in India follow the same pattern: an online test (SQL + Python + aptitude), a technical round, a case/project discussion and an HR round. The questions repeat across companies. This page collects the ones you are most likely to face – with answers you can say out loud.

The interview rounds

  1. 1Online assessment: SQL, Python, aptitude (60–90 min)
  2. 2Technical: SQL live + pandas + statistics
  3. 3Project / case discussion
  4. 4Hiring manager: problem solving, communication
  5. 5HR: expectations, notice period
A typical data-analyst interview loop

SQL questions

🗄️ SQL – click a question to see the answer

Q1. Second-highest salary (handle ties).

SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees); or DENSE_RANK() = 2 in a sub-query.

Q2. WHERE vs HAVING?

WHERE filters rows before grouping; HAVING filters groups after aggregation.

Q3. INNER vs LEFT JOIN – when do you use each?

INNER keeps only matches (clean analysis); LEFT keeps every row of the main table and adds details where available (e.g. all customers, even without orders).

Q4. How do you find duplicate emails in a users table?

SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;

Q5. Running total of daily sales?

SUM(sales) OVER (ORDER BY day) – or with PARTITION BY month for month-to-date.

Q6. ROW_NUMBER vs RANK vs DENSE_RANK?

With ties 100,100,90: ROW_NUMBER 1,2,3; RANK 1,1,3; DENSE_RANK 1,1,2.

Q7. What is a CTE and why use it?

A named temporary result (WITH x AS (…)) that makes multi-step queries readable and lets you reuse a step.

Q8. COUNT(*) vs COUNT(col)?

COUNT(*) counts rows; COUNT(col) counts non-NULL values in that column.

Python – setup for the live problems
import sqlite3
import pandas as pd
con = sqlite3.connect("bazaar.db")
pd.read_csv("sales_data.csv").to_sql("sales", con, if_exists="replace", index=False)
pd.read_csv("employees.csv").to_sql("employees", con, if_exists="replace", index=False)
pd.read_csv("departments.csv").to_sql("departments", con, if_exists="replace", index=False)
print([r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE type = 'table'")])
['sales', 'employees', 'departments']

Live problem 1: top earner per department

Python
import sqlite3
import pandas as pd
con = sqlite3.connect("bazaar.db")
q = lambda sql: pd.read_sql(sql, con)
print(q("""
WITH r AS (
    SELECT d.dept_name, e.name, e.salary,
           RANK() OVER (PARTITION BY e.dept_id ORDER BY e.salary DESC) AS rk
    FROM employees e JOIN departments d ON e.dept_id = d.dept_id
)
SELECT dept_name, name, salary FROM r WHERE rk = 1 ORDER BY salary DESC
"""))
dept_name name salary 0 Data Science Kunal 146000 1 Marketing Rohan 79000 2 Sales Vihaan 78000 3 HR Zoya 62000 4 Finance Aarav 61000

Live problem 2: month-over-month revenue growth

Python
import sqlite3
import pandas as pd
con = sqlite3.connect("bazaar.db")
q = lambda sql: pd.read_sql(sql, con)
print(q("""
WITH m AS (SELECT strftime('%m', order_date) AS month,
                  SUM(quantity * unit_price * (1 - discount)) AS rev FROM sales GROUP BY month)
SELECT month, ROUND(rev) AS revenue,
       ROUND(100.0 * (rev - LAG(rev) OVER (ORDER BY month)) / LAG(rev) OVER (ORDER BY month), 1) AS growth_pct
FROM m
""").tail(4).to_string(index=False))
month revenue growth_pct 09 445441.0 -9.4 10 861211.0 93.3 11 999630.0 16.1 12 480305.0 -52.0

Live problem 3: cities where the share of COD orders is above 20%

Python
import sqlite3
import pandas as pd
con = sqlite3.connect("bazaar.db")
q = lambda sql: pd.read_sql(sql, con)
print(q("""
SELECT city, COUNT(*) AS orders,
       ROUND(100.0 * SUM(CASE WHEN payment_mode = 'Cash on Delivery' THEN 1 ELSE 0 END) / COUNT(*), 1) AS cod_pct
FROM sales GROUP BY city HAVING cod_pct > 20 ORDER BY cod_pct DESC
"""))
city orders cod_pct 0 Hyderabad 200 22.5 1 Mumbai 252 22.2 2 Delhi 271 20.7 3 Patna 126 20.6 4 Lucknow 131 20.6 5 Ahmedabad 124 20.2

Python & pandas questions

🐍 Python & pandas

Q1. loc vs iloc?

loc uses labels (end included); iloc uses integer positions (end excluded).

Q2. How do you handle missing values in pandas?

Measure with isna().sum(); drop if few and random; fill with median/mode/group values; add a missing flag; for ML, impute inside a pipeline.

Q3. merge vs concat vs join?

merge = SQL-style join on keys; concat = stack along an axis; join = merge on the index.

Q4. agg vs transform vs apply in groupby?

agg returns one row per group; transform returns a value per original row; apply runs any function per group (most flexible, slowest).

Q5. List vs tuple vs set vs dict?

List: ordered, mutable. Tuple: ordered, immutable. Set: unique unordered items, fast membership. Dict: key → value lookup.

Q6. Why is vectorisation faster than loops?

NumPy/pandas run operations on whole arrays in optimised C code instead of executing Python bytecode per element.

Q7. What is a lambda function?

A small anonymous function: lambda x: x * 2 – handy inside apply, sort keys and map.

Live problem 4: top 2 products per category by revenue (pandas)

Python
import pandas as pd
s = pd.read_csv("sales_data.csv")
s["revenue"] = s["quantity"] * s["unit_price"] * (1 - s["discount"])
top = (s.groupby(["category", "product"], as_index=False)["revenue"].sum()
        .sort_values(["category", "revenue"], ascending=[True, False])
        .groupby("category").head(2))
print(top.round(0).to_string(index=False))
category product revenue Books & Stationery NCERT Book Set 140284.0 Books & Stationery School Bag 95070.0 Electronics Mobile Phone 1801233.0 Electronics Laptop 1417273.0 Fashion Sneakers 604886.0 Fashion Saree 340809.0 Grocery Dry Fruits 1kg 247044.0 Grocery Cooking Oil 5L 195255.0 Home & Kitchen Mixer Grinder 209764.0 Home & Kitchen Pressure Cooker 126779.0

Live problem 5: first and latest order date per city, and days between

Python
import pandas as pd
s = pd.read_csv("sales_data.csv", parse_dates=["order_date"])
g = s.groupby("city")["order_date"].agg(first="min", last="max")
g["active_days"] = (g["last"] - g["first"]).dt.days
print(g.sort_values("active_days").head(4))
first last active_days city Chennai 2024-01-02 2024-12-20 353 Lucknow 2024-01-08 2024-12-31 358 Kolkata 2024-01-05 2024-12-31 361 Patna 2024-01-02 2024-12-28 361

Live problem 6: pure Python – most frequent word

Python
from collections import Counter
text = "data beats opinions data drives decisions and good data wins"
words = text.lower().split()
print(Counter(words).most_common(2))
# without Counter:
freq = {}
for w in words:
    freq[w] = freq.get(w, 0) + 1
print(max(freq, key=freq.get), freq[max(freq, key=freq.get)])
[('data', 3), ('beats', 1)] data 3

Statistics questions

📊 Statistics & experiments

Q1. Mean vs median – which for salaries?

Median, because a few very high salaries pull the mean up.

Q2. What is a p-value?

If the null hypothesis were true, the probability of seeing results at least this extreme. Small p = evidence against H₀. Not the probability H₀ is true.

Q3. Type I vs Type II error?

Type I = false positive (reject a true H₀). Type II = false negative (miss a real effect).

Q4. Explain the Central Limit Theorem.

Means of large random samples are approximately normal around the true mean with SE = σ/√n, whatever the data’s shape.

Q5. Correlation vs causation – example?

Ice-cream sales and drownings both rise in summer (common cause: heat). Only randomised experiments establish causation.

Q6. How do you decide A/B test sample size?

From the baseline rate, minimum detectable effect, α (0.05) and power (0.8) using a power analysis – before starting the test.

Q7. What is a confidence interval?

A range from a method that captures the true parameter in, e.g., 95% of repeated samples.

Live problem 7: is the new checkout better?

Python
import pandas as pd
from statsmodels.stats.proportion import proportions_ztest
ab = pd.read_csv("ab_test.csv")
g = ab.groupby("group")["converted"].agg(["sum", "count"])
z, p = proportions_ztest(g.loc[["B", "A"], "sum"], g.loc[["B", "A"], "count"])
print((g["sum"] / g["count"]).round(4).to_dict(), f"| z = {z:.2f}, p = {p:.4f} →", "B is better" if p < 0.05 and z > 0 else "no clear winner")
{'A': 0.1072, 'B': 0.1359} | z = 2.78, p = 0.0055 → B is better

Machine-learning questions

🤖 Machine learning

Q1. Bias–variance trade-off?

Simple models have high bias (underfit); complex models high variance (overfit). Tune complexity with validation to minimise total error.

Q2. Precision vs recall – which for fraud?

Recall (catch most fraud), balanced with an acceptable precision; choose the threshold by the cost of each error.

Q3. Why is accuracy misleading on imbalanced data?

Predicting the majority class gets high accuracy but finds nothing. Use precision, recall, F1, PR-AUC.

Q4. Random forest vs gradient boosting?

Forest: parallel trees on bootstrap samples, averages, robust. Boosting: sequential trees fixing errors, often most accurate, needs tuning.

Q5. What is data leakage? Give an example.

Training uses information unavailable at prediction time – e.g. “refund_issued” to predict complaints, or scaling before splitting.

Q6. Why use cross-validation?

A more reliable estimate than one split (mean ± std) using all data for training and validation.

Q7. L1 vs L2 regularisation?

L1 (Lasso) can zero coefficients – feature selection. L2 (Ridge) shrinks all smoothly – good with correlated features.

Q8. How do you choose k in K-Means?

Elbow of inertia, silhouette score, and business usefulness of the segments.

Q9. How would you explain a model to a manager?

Lead with the business outcome, show top drivers (coefficients / permutation importance), give an example prediction with reasons, and state limits.

Live problem 8: train, evaluate and explain in 10 lines

Python
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score, classification_report
l = pd.read_csv("loan_applications.csv"); l["lti"] = l["loan_amount"] / (l["monthly_income"] * 12)
X, y = l[["credit_score", "lti", "years_employed", "monthly_income"]], l["approved"]
a, b, c, d = train_test_split(X, y, test_size=0.25, random_state=0, stratify=y)
m = RandomForestClassifier(n_estimators=300, min_samples_leaf=5, random_state=0).fit(a, c)
print("AUC", round(roc_auc_score(d, m.predict_proba(b)[:, 1]), 3))
print(pd.Series(m.feature_importances_, index=X.columns).round(3).sort_values(ascending=False).to_dict())
AUC 0.9 {'credit_score': 0.682, 'lti': 0.177, 'monthly_income': 0.083, 'years_employed': 0.058}

Case & product questions

🧩 Case studies

Q1. Daily orders dropped 20% yesterday. How do you investigate?

Check data/tracking issues first; then segment by platform, city, category, channel and new vs returning users; compare with the same weekday last week; look for external events (outage, holiday, competitor sale); quantify and report.

Q2. Which metrics would you track for a food-delivery app?

North star: weekly orders. Inputs: active users, conversion, AOV, delivery time, cancellation rate, repeat rate, restaurant availability; guardrails: refund rate, ratings.

Q3. Estimate the number of UPI transactions in a day in your city.

Structure it: population × share using UPI × transactions per user per day, sanity-check with known national numbers, and state assumptions clearly.

💡 How to answer any case

Clarify the goal → list hypotheses → say which data you would check → segment → quantify → recommend. Think out loud; structure matters more than the “right” number.

7-day revision plan

DayRevisePractice
1SQL basics, joins (Days 32–33)15 SQL problems
2Window functions, CTEs (Day 34)10 hard SQL problems
3pandas (Days 10–20)Day 20 test again, timed
4Statistics & A/B (Days 26–31)Explain p-value, CI, CLT aloud
5ML concepts + metrics (Days 36–45)Train/evaluate in 15 minutes
6Your projects2-minute pitch for each project
7Mock interview + HR answersRecord yourself, fix filler words

🏅 Job skills unlocked today

✔ Answer common SQL, Python, statistics and ML questions✔ Solve live coding problems under time pressure✔ Structure case-study answers✔ Plan focused revision

Practice tasks

🏋️ Practice – do it yourself

Task 1: SQL: find customers (cities here) whose revenue grew in every quarter of 2024.
Show solution
Python
import sqlite3
import pandas as pd
con = sqlite3.connect("bazaar.db")
q = lambda sql: pd.read_sql(sql, con)
print(q("""WITH cq AS (SELECT city, (CAST(strftime('%m', order_date) AS INT) + 2) / 3 AS qtr, SUM(quantity*unit_price*(1-discount)) AS rev FROM sales GROUP BY city, qtr),
g AS (SELECT city, qtr, rev, LAG(rev) OVER (PARTITION BY city ORDER BY qtr) AS prev FROM cq)
SELECT city FROM g WHERE qtr > 1 GROUP BY city HAVING SUM(CASE WHEN rev > prev THEN 1 ELSE 0 END) = 3"""))
print("Only these cities grew in Q2, Q3 and Q4 – a rare, consistent performer.")
city 0 Pune Only these cities grew in Q2, Q3 and Q4 – a rare, consistent performer.
Task 2: pandas: for each region, which payment mode has the highest average order value?
Show solution
Python
import pandas as pd
s = pd.read_csv("sales_data.csv"); s["rev"] = s["quantity"] * s["unit_price"] * (1 - s["discount"])
a = s.groupby(["region", "payment_mode"])["rev"].mean().reset_index()
print(a.loc[a.groupby("region")["rev"].idxmax()].round(0).to_string(index=False))
region payment_mode rev East Cash on Delivery 5450.0 North Card 3703.0 South Net Banking 3417.0 West Cash on Delivery 5696.0
Task 3: Record a 2-minute answer to “Walk me through your churn project” after Day 60.

Quick quiz

🧠 Quick Quiz – test yourself

1. Logical order of SQL execution starts with…
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT.
2. A model has 95% train and 70% test accuracy. Best first fix?
It is overfitting.
3. p = 0.03 in an A/B test with α = 0.05. You…
Also check practical significance.
4. Fastest way to get top-N per group in pandas?
Or nlargest inside groupby.
5. Best structure for a case question?
Think out loud.

Interview corner

💼 Interview Corner

What is your biggest weakness?

Pick a real, non-critical skill you are actively improving, with evidence: “I used to over-polish charts; now I timebox analysis and share drafts early – my last project went from idea to deployed app in 5 days.”

Do you have any questions for us?

Always yes: “What does success look like in the first 90 days?”, “Which tools and data does the team use?”, “How do analysts work with product and business teams?”

Summary

  • Interviews test SQL, pandas, statistics, ML and communication.
  • Practise live problems with a timer – and explain while you code.
  • Structure case answers; always quantify.
  • Next: the 5-day major project that ties everything together.
➡️ Next

Major project begins! Day 56: telecom churn – define the business problem and plan the solution.

Frequently Asked Questions

Where can I practise more SQL?
LeetCode (database section), HackerRank SQL, StrataScratch and DataLemur have real interview questions from Indian and global companies.
What if I do not know an answer?
Say so honestly, explain how you would find out or reason about it, and connect to something related you do know. Interviewers value clear thinking over memorised facts.
← Data Science (60 Days)
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicDay 56: Project 1: Business Problem & Data Your progress: 55 / 60 (92%) · Lesson 56 / 60 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free