{"id":3462,"date":"2026-10-12T06:37:59","date_gmt":"2026-10-12T06:37:59","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=3462"},"modified":"2026-10-13T02:52:15","modified_gmt":"2026-10-13T02:52:15","slug":"data-science-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/","title":{"rendered":"Top 50 Data Science Interview Questions and Answers with Examples"},"content":{"rendered":"<h1><strong><b>Data Science Interview Questions and Answers<\/b><\/strong><\/h1>\n<p>Data science interviews have changed. A few years ago most of the questions were definitions of statistics terms. Today employers test whether you can get data with SQL, clean and explore it in pandas, reason about statistics and experiments, build a sensible model, and explain the result to people who do not write code. This guide gives you 50 data science interview questions and answers that follow that structure.<\/p>\n<p>Every answer starts with a short, direct response you can say aloud, followed by detail, a table or working code. The SQL examples were run in SQLite and the Python examples were run before they were added, so the printed output under each sample is the real result. Formulas are written in words, so nothing depends on an image. Where a topic needs more depth, the answer points you to the Statistics, Machine Learning or Python interview pages.<\/p>\n<p>The guide has eight parts: 8 questions on basics and workflow, 9 on SQL, 5 on pandas, 8 on statistics essentials, 4 on machine learning essentials, 7 on A B testing, 4 case studies and 5 project and behavioural questions. Freshers can start at the top. Experienced candidates should go straight to experimentation, case studies and project questions.<\/p>\n<h3><strong><b>Key points<\/b><\/strong><\/h3>\n<ul>\n<li>50 questions in eight parts, from workflow and SQL to case studies.<\/li>\n<li>Every answer opens with a short answer you can say in an interview.<\/li>\n<li>SQL and Python examples were run, and the real output is shown.<\/li>\n<li>Statistics and machine learning are covered briefly, with links to the full pages.<\/li>\n<li>Includes A B testing and case study answers with what the interviewer is listening for.<\/li>\n<\/ul>\n<h3><strong><b>In this guide<\/b><\/strong><\/h3>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 520px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">What this guide covers<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Section<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 140px;\" scope=\"col\">Questions<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Data Science Basics and Workflow (Freshers)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q1 to Q8<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">SQL for Data Science (Freshers and Intermediate)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q9 to Q17<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Python and pandas for Data Science (Freshers and Intermediate)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q18 to Q22<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Statistics Essentials for Data Science (Intermediate)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q23 to Q30<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Machine Learning Essentials for Data Science (Intermediate)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q31 to Q34<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">A B Testing and Experimentation (Intermediate and Experienced)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q35 to Q41<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Case Study Questions (Experienced)<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;\">Q42 to Q45<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a;\" scope=\"row\">Project and Behavioural Questions (All Levels)<\/th>\n<td style=\"padding: 12px 16px; white-space: nowrap;\">Q46 to Q50<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2><strong><b>Data Science Basics and Workflow (Freshers)<\/b><\/strong><\/h2>\n<p>Freshers are usually asked how data science work is organised and how it differs from neighbouring roles. Answer with the full project flow in mind, from the business question to a monitored result.<\/p>\n<h3><strong><b>Q1. What is data science, and how does it differ from data analytics and machine learning engineering?<\/b><\/strong><\/h3>\n<p>Data science uses statistics, programming and domain knowledge to answer business questions and build predictive models from data. Data analytics focuses on describing what happened and why, usually with SQL and dashboards. Machine learning engineering focuses on deploying and running models reliably in production. In small teams one person often does all three.<\/p>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 720px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Data analyst, data scientist and machine learning engineer compared<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 170px;\" scope=\"col\">Role<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Main question<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Typical tools<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Typical output<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Data analyst<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">What happened, and why?<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">SQL, Excel, Power BI, Tableau, basic Python<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Reports, dashboards, insights<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Data scientist<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">What will happen, and what should we do?<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Python, SQL, statistics, scikit learn<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Models, experiments, recommendations<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a;\" scope=\"row\">Machine learning engineer<\/th>\n<td style=\"padding: 12px 16px;\">How do we run this model reliably at scale?<\/td>\n<td style=\"padding: 12px 16px;\">Python, cloud services, pipelines, monitoring<\/td>\n<td style=\"padding: 12px 16px;\">Deployed and monitored model services<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q2. What are the steps in a data science project?<\/b><\/strong><\/h3>\n<p>A typical project moves through problem definition, data collection, cleaning, exploratory analysis, feature engineering, modelling, evaluation, deployment and monitoring. The steps repeat, because results from modelling often send you back to the data. The first step matters most, since a model built for the wrong question has no value.<\/p>\n<ul>\n<li>Define the business question and how success will be measured.<\/li>\n<li>Collect and join the data, then clean it and check its quality.<\/li>\n<li>Explore the data to find patterns, gaps and problems.<\/li>\n<li>Build features, train models and compare them with a simple baseline.<\/li>\n<li>Evaluate on unseen data using a metric that matches the business cost.<\/li>\n<li>Deploy the model, then monitor it for drift and decay.<\/li>\n<\/ul>\n<h3><strong><b>Q3. What are structured, semi structured and unstructured data?<\/b><\/strong><\/h3>\n<p>Structured data fits rows and columns with a fixed schema, such as a sales table. Semi structured data has tags or keys but no rigid schema, such as JSON and XML files. Unstructured data has no predefined format, such as free text, images, audio and video. Each needs different storage and processing tools.<\/p>\n<h3><strong><b>Q4. What is exploratory data analysis, and what do you check first?<\/b><\/strong><\/h3>\n<p>Exploratory data analysis is looking at the data before modelling to understand its shape, quality and patterns. Start with the number of rows and columns, the data types, missing values, duplicates, and summary statistics. Then look at distributions, outliers, and relationships between features and the target.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\nimport numpy as np\r\n\r\nrng = np.random.default_rng(0)\r\ndf = pd.DataFrame({\r\n    \"age\": rng.integers(21, 60, 8).astype(float),\r\n    \"city\": [\"Pune\", \"Pune\", \"Bangalore\", None, \"Pune\", \"Bangalore\", \"Bangalore\", \"Pune\"],\r\n    \"spend\": [1200, 800, 1500, 900, 99999, 1100, 700, 1300],\r\n})\r\ndf.loc[2, \"age\"] = None\r\n\r\nprint(df.shape)\r\nprint(df.dtypes.to_string())\r\nprint(df.isna().sum().to_string())\r\nprint(df[\"spend\"].describe().round(1).to_string())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">(8, 3)\r\nage      float64\r\ncity         str\r\nspend      int64\r\nage      1\r\ncity     1\r\nspend    0\r\ncount        8.0\r\nmean     13437.4\r\nstd      34977.2\r\nmin        700.0\r\n25%        875.0\r\n50%       1150.0\r\n75%       1350.0\r\nmax      99999.0<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The maximum spend is far above the rest in the printed summary, which is the kind of outlier to investigate before modelling.<\/p>\n<h3><strong><b>Q5. How do you check the quality of a dataset before trusting it?<\/b><\/strong><\/h3>\n<p>Check completeness, uniqueness, validity, consistency and freshness. Look for missing values, duplicate keys, values outside a sensible range, categories spelled in different ways, dates that do not make sense, and totals that do not match the source system. Write these checks as code so they run again each time the data refreshes.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\norders = pd.DataFrame({\r\n    \"order_id\": [1, 2, 2, 4],\r\n    \"amount\": [500, -20, -20, 750],\r\n    \"status\": [\"Paid\", \"paid\", \"paid\", \"Refunded\"],\r\n    \"order_date\": pd.to_datetime([\"2026-01-05\", \"2026-01-06\", \"2026-01-06\", \"2027-03-01\"]),\r\n})\r\n\r\nchecks = {\r\n    \"duplicate order ids\": orders[\"order_id\"].duplicated().sum(),\r\n    \"negative amounts\": (orders[\"amount\"] &lt; 0).sum(),\r\n    \"inconsistent status spellings\": orders[\"status\"].nunique() - orders[\"status\"].str.lower().nunique(),\r\n    \"dates in the future\": (orders[\"order_date\"] &gt; \"2026-12-31\").sum(),\r\n}\r\n\r\nfor name, count in checks.items():\r\n    print(f\"{name}: {count}\")<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">duplicate order ids: 1\r\nnegative amounts: 2\r\ninconsistent status spellings: 1\r\ndates in the future: 1<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q6. What is the difference between ETL and ELT?<\/b><\/strong><\/h3>\n<p>ETL extracts data, transforms it on a separate processing server, and then loads the result into the warehouse. ELT loads the raw data into the warehouse first and transforms it there using the warehouse engine. ELT is common with modern cloud warehouses because storage is cheap and the raw data stays available for new questions.<\/p>\n<h3><strong><b>Q7. How do you choose the right metrics for a business problem?<\/b><\/strong><\/h3>\n<p>Start from the decision the metric will support. A good metric is tied to the business goal, can be measured reliably, is hard to game and moves when the real outcome moves. Pair a main metric with guardrail metrics that catch harm, for example pairing conversion with refund rate.<\/p>\n<h3><strong><b>Q8. Which tools and technologies does a data scientist use day to day?<\/b><\/strong><\/h3>\n<p>Most data scientists use Python or R for analysis and modelling, SQL for getting data, Jupyter notebooks or an editor for development, and Git for version control. Visualisation tools such as Power BI or Tableau help with sharing results, and cloud platforms such as AWS, Azure or Google Cloud host larger workloads.<\/p>\n<h2><strong><b>SQL for Data Science (Freshers and Intermediate)<\/b><\/strong><\/h2>\n<p>Almost every data science interview includes a live SQL question. The examples below were run in SQLite, and the same ideas work in MySQL, PostgreSQL and SQL Server with minor changes in syntax.<\/p>\n<h3><strong><b>Q9. What is the difference between WHERE and HAVING?<\/b><\/strong><\/h3>\n<p>WHERE filters individual rows before grouping happens, and HAVING filters the groups after aggregation. You cannot use an aggregate such as COUNT or AVG inside WHERE. Use WHERE to reduce the data early, which is faster, and HAVING for conditions on the grouped result.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE emp (name TEXT, dept TEXT, salary INT);\r\nINSERT INTO emp VALUES ('Asha','Data',90000),('Ravi','Data',120000),\r\n                       ('Kiran','Sales',70000),('Divya','Sales',85000),('Imran','HR',60000);\r\n\"\"\")\r\n\r\nquery = \"\"\"\r\nSELECT dept, COUNT(*) AS people, AVG(salary) AS avg_salary\r\nFROM emp\r\nWHERE salary &gt; 65000\r\nGROUP BY dept\r\nHAVING COUNT(*) &gt;= 2\r\nORDER BY dept\r\n\"\"\"\r\n\r\nfor row in con.execute(query):\r\n    print(row)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">('Data', 2, 105000.0)\r\n('Sales', 2, 77500.0)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q10. What are the different types of joins?<\/b><\/strong><\/h3>\n<p>An inner join returns only rows that match in both tables. A left join returns all rows from the left table and the matches from the right, with nulls where there is no match. A right join does the reverse, and a full outer join returns all rows from both. A cross join pairs every row with every row.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE customers (id INT, name TEXT);\r\nCREATE TABLE orders (id INT, customer_id INT, amount INT);\r\nINSERT INTO customers VALUES (1,'Asha'),(2,'Ravi'),(3,'Meena');\r\nINSERT INTO orders VALUES (10,1,500),(11,1,300),(12,2,700);\r\n\"\"\")\r\n\r\nprint(\"inner join\")\r\nfor r in con.execute(\"SELECT c.name, o.amount FROM customers c JOIN orders o ON o.customer_id = c.id\"):\r\n    print(r)\r\n\r\nprint(\"left join, customers with no orders\")\r\nfor r in con.execute(\"\"\"SELECT c.name FROM customers c\r\n                        LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL\"\"\"):\r\n    print(r)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">inner join\r\n('Asha', 300)\r\n('Asha', 500)\r\n('Ravi', 700)\r\nleft join, customers with no orders\r\n('Meena',)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The left join with a null check is the standard way to find rows in one table that have no match in another.<\/p>\n<h3><strong><b>Q11. What are window functions, and how do you get the top earner in each department?<\/b><\/strong><\/h3>\n<p>A window function calculates a value across a set of related rows without collapsing them into one row, as GROUP BY does. Use ROW_NUMBER, RANK or DENSE_RANK with PARTITION BY and ORDER BY to rank rows inside each group, then keep rank 1 in an outer query.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE emp (name TEXT, dept TEXT, salary INT);\r\nINSERT INTO emp VALUES ('Asha','Data',90000),('Ravi','Data',120000),('Meena','Data',110000),\r\n                       ('Kiran','Sales',70000),('Divya','Sales',85000),('Imran','HR',60000);\r\n\"\"\")\r\n\r\nquery = \"\"\"\r\nSELECT dept, name, salary FROM (\r\n    SELECT *, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn\r\n    FROM emp\r\n) WHERE rn = 1 ORDER BY dept\r\n\"\"\"\r\n\r\nfor row in con.execute(query):\r\n    print(row)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">('Data', 'Ravi', 120000)\r\n('HR', 'Imran', 60000)\r\n('Sales', 'Divya', 85000)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q12. How do you find the second highest salary?<\/b><\/strong><\/h3>\n<p>Rank the distinct salaries with DENSE_RANK in descending order and pick rank 2. DENSE_RANK is safer than ROW_NUMBER because tied salaries share a rank and do not hide the next value. A simpler version uses a subquery with MAX of the salaries below the overall maximum.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE emp (name TEXT, salary INT);\r\nINSERT INTO emp VALUES ('Asha',90000),('Ravi',120000),('Meena',120000),('Kiran',70000);\r\n\"\"\")\r\n\r\nquery = \"\"\"\r\nSELECT DISTINCT salary FROM (\r\n    SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS r FROM emp\r\n) WHERE r = 2\r\n\"\"\"\r\n\r\nprint(con.execute(query).fetchall())\r\nprint(con.execute(\"SELECT MAX(salary) FROM emp WHERE salary &lt; (SELECT MAX(salary) FROM emp)\").fetchall())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">[(90000,)]\r\n[(90000,)]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q13. How do you find and remove duplicate rows?<\/b><\/strong><\/h3>\n<p>Group by the columns that define a duplicate and keep only groups with a count above one to find them. To remove them, keep one row per group, for example the row with the smallest row id, and delete the rest. Always run the select version first so you see what will be deleted.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE leads (email TEXT, city TEXT);\r\nINSERT INTO leads VALUES ('a@x.com','Pune'),('b@x.com','Bangalore'),('a@x.com','Pune'),('a@x.com','Pune');\r\n\"\"\")\r\n\r\nprint(con.execute(\"SELECT email, COUNT(*) FROM leads GROUP BY email HAVING COUNT(*) &gt; 1\").fetchall())\r\n\r\ncon.execute(\"DELETE FROM leads WHERE rowid NOT IN (SELECT MIN(rowid) FROM leads GROUP BY email)\")\r\nprint(con.execute(\"SELECT * FROM leads\").fetchall())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">[('a@x.com', 3)]\r\n[('a@x.com', 'Pune'), ('b@x.com', 'Bangalore')]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q14. What are CTEs and subqueries, and how do you calculate month over month growth?<\/b><\/strong><\/h3>\n<p>A subquery is a query inside another query, and a common table expression, or CTE, names a subquery with WITH so it reads top to bottom. Use a CTE to build monthly totals, then use the LAG window function to bring in the previous month and calculate the percentage change.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE sales (month TEXT, revenue INT);\r\nINSERT INTO sales VALUES ('2026-01',100000),('2026-02',120000),('2026-03',90000);\r\n\"\"\")\r\n\r\nquery = \"\"\"\r\nWITH monthly AS (\r\n    SELECT month, SUM(revenue) AS revenue FROM sales GROUP BY month\r\n)\r\nSELECT month, revenue,\r\n       ROUND(100.0 * (revenue - LAG(revenue) OVER (ORDER BY month))\r\n             \/ LAG(revenue) OVER (ORDER BY month), 1) AS growth_pct\r\nFROM monthly\r\n\"\"\"\r\n\r\nfor row in con.execute(query):\r\n    print(row)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">('2026-01', 100000, None)\r\n('2026-02', 120000, 20.0)\r\n('2026-03', 90000, -25.0)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q15. How does SQL handle NULL values?<\/b><\/strong><\/h3>\n<p>NULL means unknown, so it is not equal to anything, including another NULL. Use IS NULL and IS NOT NULL to test for it. COUNT of a column ignores NULLs, while COUNT of star counts every row. Use COALESCE to replace NULL with a default value in a result.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"\"\"\r\nCREATE TABLE t (name TEXT, phone TEXT);\r\nINSERT INTO t VALUES ('Asha','98450'),('Ravi',NULL),('Meena',NULL);\r\n\"\"\")\r\n\r\nprint(con.execute(\"SELECT COUNT(*), COUNT(phone) FROM t\").fetchall())\r\nprint(con.execute(\"SELECT name, COALESCE(phone, 'not given') FROM t\").fetchall())\r\nprint(con.execute(\"SELECT COUNT(*) FROM t WHERE phone = NULL\").fetchall())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">[(3, 1)]\r\n[('Asha', '98450'), ('Ravi', 'not given'), ('Meena', 'not given')]\r\n[(0,)]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The last query returns 0 because a comparison with NULL is never true. The correct test is IS NULL.<\/p>\n<h3><strong><b>Q16. What is the difference between UNION and UNION ALL?<\/b><\/strong><\/h3>\n<p>UNION combines the results of two queries and removes duplicate rows, which needs extra work to sort or hash the rows. UNION ALL combines them and keeps every row, so it is faster. Use UNION ALL unless you specifically need duplicates removed. Both need the same number of columns with compatible types.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\n\r\nprint(con.execute(\"SELECT 1 UNION SELECT 1 UNION SELECT 2\").fetchall())\r\nprint(con.execute(\"SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 2\").fetchall())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">[(1,), (2,)]\r\n[(1,), (1,), (2,)]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q17. What is an index, and how does it speed up a query?<\/b><\/strong><\/h3>\n<p>An index is a separate sorted structure, usually a B tree, that lets the database find rows without scanning the whole table. It speeds up filters, joins and sorts on the indexed columns, but it takes storage and slows down inserts and updates. Index the columns you filter and join on most often.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import sqlite3\r\n\r\ncon = sqlite3.connect(\":memory:\")\r\ncon.executescript(\"CREATE TABLE emp (id INT, dept TEXT, salary INT);\")\r\n\r\nplan = \"EXPLAIN QUERY PLAN SELECT * FROM emp WHERE dept = 'Data'\"\r\nprint(\"before:\", con.execute(plan).fetchall()[0][3])\r\n\r\ncon.execute(\"CREATE INDEX idx_dept ON emp(dept)\")\r\nprint(\"after: \", con.execute(plan).fetchall()[0][3])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">before: SCAN emp\r\nafter:  SEARCH emp USING INDEX idx_dept (dept=?)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><strong><b>Python and pandas for Data Science (Freshers and Intermediate)<\/b><\/strong><\/h2>\n<p>These questions focus on the pandas work that fills a data scientist day. For core Python topics such as decorators, generators and the GIL, see the Python interview questions page.<\/p>\n<h3><strong><b>Q18. How do you clean duplicates and wrong data types in pandas?<\/b><\/strong><\/h3>\n<p>Use drop_duplicates to remove repeated rows, optionally on a subset of columns, and astype or the to_datetime and to_numeric functions to fix types. Set errors to coerce so that bad values become missing instead of stopping the code, then inspect those missing values on purpose.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\ndf = pd.DataFrame({\r\n    \"id\": [1, 2, 2, 3],\r\n    \"amount\": [\"500\", \"700\", \"700\", \"n\/a\"],\r\n    \"joined\": [\"2026-01-05\", \"2026-02-10\", \"2026-02-10\", \"2026-03-15\"],\r\n})\r\n\r\ndf = df.drop_duplicates()\r\ndf[\"amount\"] = pd.to_numeric(df[\"amount\"], errors=\"coerce\")\r\ndf[\"joined\"] = pd.to_datetime(df[\"joined\"])\r\n\r\nprint(df)\r\nprint(df.dtypes.to_string())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">   id  amount     joined\r\n0   1   500.0 2026-01-05\r\n1   2   700.0 2026-02-10\r\n3   3     NaN 2026-03-15\r\nid                 int64\r\namount           float64\r\njoined    datetime64[us]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q19. What is the difference between groupby and pivot_table?<\/b><\/strong><\/h3>\n<p>Both summarise data by categories. The groupby method returns a long format result with one row per group, and pivot_table arranges one category across the rows and another across the columns, like an Excel pivot. Use pivot_table when you want a cross tab for a report, and groupby when you will keep processing the result.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\ndf = pd.DataFrame({\r\n    \"city\": [\"Pune\", \"Pune\", \"Bangalore\", \"Bangalore\", \"Pune\"],\r\n    \"course\": [\"Python\", \"SQL\", \"Python\", \"SQL\", \"Python\"],\r\n    \"fee\": [18000, 12000, 18000, 12000, 18000],\r\n})\r\n\r\nprint(df.groupby([\"city\", \"course\"])[\"fee\"].sum())\r\nprint(df.pivot_table(index=\"city\", columns=\"course\", values=\"fee\", aggfunc=\"sum\"))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">city       course\r\nBangalore  Python    18000\r\n           SQL       12000\r\nPune       Python    36000\r\n           SQL       12000\r\nName: fee, dtype: int64\r\ncourse     Python    SQL\r\ncity                    \r\nBangalore   18000  12000\r\nPune        36000  12000<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q20. How do you calculate rolling averages and resample time series in pandas?<\/b><\/strong><\/h3>\n<p>Set the date column as the index, then use rolling with a window size for a moving average, and resample with a frequency such as weekly or monthly to aggregate over time. Rolling averages smooth short term noise so that the trend is easier to see.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\ns = pd.Series([10, 12, 9, 14, 20, 18, 22],\r\n              index=pd.date_range(\"2026-01-01\", periods=7, freq=\"D\"))\r\n\r\nprint(s.rolling(3).mean().round(2).to_string())\r\nprint(s.resample(\"W\").sum().to_string())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">2026-01-01      NaN\r\n2026-01-02      NaN\r\n2026-01-03    10.33\r\n2026-01-04    11.67\r\n2026-01-05    14.33\r\n2026-01-06    17.33\r\n2026-01-07    20.00\r\nFreq: D\r\n2026-01-04    45\r\n2026-01-11    60\r\nFreq: W-SUN<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q21. What can go wrong when you merge two tables in pandas?<\/b><\/strong><\/h3>\n<p>The most common problem is a many to many join, where the join key repeats in both tables and the number of rows multiplies, which quietly inflates totals. Check key uniqueness before merging, use the validate argument to enforce the expected relationship, and compare row counts and totals after the merge.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\na = pd.DataFrame({\"id\": [1, 1], \"x\": [10, 20]})\r\nb = pd.DataFrame({\"id\": [1, 1], \"y\": [100, 200]})\r\n\r\nprint(len(a.merge(b, on=\"id\")), \"rows after merging two 2 row tables\")\r\n\r\ntry:\r\n    a.merge(b, on=\"id\", validate=\"one_to_one\")\r\nexcept Exception as e:\r\n    print(type(e).__name__)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">4 rows after merging two 2 row tables\r\nMergeError<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q22. How do you work with a file that is too large to load into memory?<\/b><\/strong><\/h3>\n<p>Read it in chunks with the chunksize argument and aggregate each chunk, load only the columns you need with usecols, use smaller data types such as category and int32, or convert the file to a columnar format such as Parquet. For data far beyond one machine, use a distributed tool such as Spark.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\npd.DataFrame({\"city\": [\"Pune\", \"Bangalore\"] * 5000, \"fee\": range(10000)}).to_csv(\"big.csv\", index=False)\r\n\r\ntotal = 0\r\nfor chunk in pd.read_csv(\"big.csv\", usecols=[\"fee\"], chunksize=2500):\r\n    total += chunk[\"fee\"].sum()\r\n\r\nprint(total)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">49995000<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><strong><b>Statistics Essentials for Data Science (Intermediate)<\/b><\/strong><\/h2>\n<p>These are the statistics ideas that data science interviews return to most often. Each answer is short on purpose. A fuller set with worked examples is on the Statistics interview questions page.<\/p>\n<h3><strong><b>Q23. What is the difference between a population and a sample, and what is inferential statistics?<\/b><\/strong><\/h3>\n<p>A population is the full group you want to understand, and a sample is the part of it you actually measure. Descriptive statistics summarise the sample. Inferential statistics use the sample to draw conclusions about the population, with a measure of uncertainty, through estimates, confidence intervals and hypothesis tests.<\/p>\n<h3><strong><b>Q24. What is a p value?<\/b><\/strong><\/h3>\n<p>A p value is the probability of seeing a result at least as extreme as the one observed, if the null hypothesis is true. A small p value is evidence against the null hypothesis. It is not the probability that the null hypothesis is true, and it does not measure the size of an effect.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\nfrom scipy import stats\r\n\r\nrng = np.random.default_rng(42)\r\nold_page = rng.normal(50, 10, 200)\r\nnew_page = rng.normal(53, 10, 200)\r\n\r\nt, p = stats.ttest_ind(new_page, old_page)\r\nprint(\"t statistic:\", round(t, 2))\r\nprint(\"p value:\", round(p, 4))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">t statistic: 3.68\r\np value: 0.0003<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>A common threshold is 0.05, but it is a convention. Decide the threshold before you run the test, and report the effect size along with the p value.<\/p>\n<h3><strong><b>Q25. What are Type I and Type II errors, and what is statistical power?<\/b><\/strong><\/h3>\n<p>A Type I error is rejecting a true null hypothesis, a false alarm, and its probability is the significance level alpha. A Type II error is failing to reject a false null hypothesis, a missed effect, with probability beta. Power is 1 minus beta, the chance of detecting a real effect, and a common target is 80 percent.<\/p>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 600px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Type I and Type II errors<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 200px;\" scope=\"col\">Decision<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Null hypothesis is true<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Null hypothesis is false<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a;\" scope=\"row\">Reject the null hypothesis<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Type I error (false positive)<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Correct decision, this is power<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a;\" scope=\"row\">Fail to reject the null hypothesis<\/th>\n<td style=\"padding: 12px 16px;\">Correct decision<\/td>\n<td style=\"padding: 12px 16px;\">Type II error (false negative)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q26. What is the central limit theorem, and why does it matter?<\/b><\/strong><\/h3>\n<p>The central limit theorem says that the distribution of sample means approaches a normal distribution as the sample size grows, whatever the shape of the original data, provided the variance is finite. It matters because it lets us use normal based confidence intervals and tests on averages, even when the raw data is skewed.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\n\r\nrng = np.random.default_rng(1)\r\nskewed = rng.exponential(scale=2.0, size=100_000)       # strongly skewed data\r\nmeans = [rng.choice(skewed, 50).mean() for _ in range(2000)]\r\n\r\nprint(\"population mean:     \", round(skewed.mean(), 2))\r\nprint(\"mean of sample means:\", round(np.mean(means), 2))\r\nprint(\"spread of the means: \", round(np.std(means), 2), \"(about population std divided by square root of 50)\")\r\nprint(\"population std \/ sqrt(50):\", round(skewed.std() \/ 50 ** 0.5, 2))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">population mean:      1.99\r\nmean of sample means: 1.99\r\nspread of the means:  0.28 (about population std divided by square root of 50)\r\npopulation std \/ sqrt(50): 0.28<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q27. What is a confidence interval, and how do you read one?<\/b><\/strong><\/h3>\n<p>A 95 percent confidence interval is a range calculated so that, if you repeated the study many times, about 95 percent of the intervals built this way would contain the true value. It does not mean there is a 95 percent chance the true value lies in this one interval. A narrower interval means a more precise estimate.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\nfrom scipy import stats\r\n\r\nrng = np.random.default_rng(7)\r\ndata = rng.normal(100, 15, 40)\r\n\r\nmean = data.mean()\r\nlow, high = stats.t.interval(0.95, df=len(data) - 1, loc=mean, scale=stats.sem(data))\r\n\r\nprint(round(mean, 1), (round(float(low), 1), round(float(high), 1)))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">94.1 (90.1, 98.0)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q28. What is the normal distribution, and what does a z score tell you?<\/b><\/strong><\/h3>\n<p>The normal distribution is a symmetric bell shaped distribution described by its mean and standard deviation. It is common in theory because of the central limit theorem, but many real variables are not normal. A z score is the number of standard deviations a value lies from the mean. It is not limited to a fixed range.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">from scipy import stats\r\n\r\nmean, std = 70, 10\r\nscore = 95\r\nz = (score - mean) \/ std\r\n\r\nprint(\"z score:\", z)\r\nprint(\"share of values below this score:\", round(stats.norm.cdf(z), 4))\r\nprint(\"within 1, 2, 3 std:\", [round(float(stats.norm.cdf(k) - stats.norm.cdf(-k)), 3) for k in (1, 2, 3)])<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">z score: 2.5\r\nshare of values below this score: 0.9938\r\nwithin 1, 2, 3 std: [0.683, 0.954, 0.997]<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The rule of thumb that about 99.7 percent of values lie within three standard deviations applies to normal data only. It is often used to flag outliers, but it is not a limit on the z score.<\/p>\n<h3><strong><b>Q29. What is the difference between correlation and causation?<\/b><\/strong><\/h3>\n<p>Correlation means two variables move together. Causation means a change in one produces a change in the other. A correlation can come from a third factor that drives both, from chance, or from reverse causation. A randomised experiment is the strongest way to show causation, because it removes other explanations.<\/p>\n<p>Example to use in an interview: ice cream sales and drowning incidents both rise in summer. Heat drives both, so neither causes the other.<\/p>\n<h3><strong><b>Q30. When do you use the mean and when the median?<\/b><\/strong><\/h3>\n<p>Use the mean for roughly symmetric data without extreme values, since it uses every value. Use the median when the data is skewed or has outliers, because it is not pulled by a few extreme values. Income and house prices are typical cases where the median describes a typical value better.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\n\r\nsalaries = np.array([30, 32, 35, 36, 38, 40, 400])   # in thousands\r\n\r\nprint(\"mean:  \", salaries.mean().round(1))\r\nprint(\"median:\", np.median(salaries))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">mean:   87.3\r\nmedian: 36.0<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><strong><b>Machine Learning Essentials for Data Science (Intermediate)<\/b><\/strong><\/h2>\n<p>Data science interviews include machine learning, but usually test judgement more than algorithm detail. These answers are brief. The Machine Learning interview questions page covers each topic in depth.<\/p>\n<h3><strong><b>Q31. How do you start a modelling problem, and why use a baseline?<\/b><\/strong><\/h3>\n<p>Begin with a simple baseline, such as predicting the most common class, the average, or a basic linear model. The baseline tells you whether a complex model adds real value, and it often catches data problems early. If a sophisticated model only beats the baseline by a hair, the extra complexity is rarely worth it.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">from sklearn.datasets import make_classification\r\nfrom sklearn.dummy import DummyClassifier\r\nfrom sklearn.ensemble import RandomForestClassifier\r\nfrom sklearn.linear_model import LogisticRegression\r\nfrom sklearn.model_selection import cross_val_score\r\n\r\nX, y = make_classification(n_samples=800, n_features=10, n_informative=4, random_state=21)\r\n\r\nmodels = {\r\n    \"baseline (most frequent)\": DummyClassifier(strategy=\"most_frequent\"),\r\n    \"logistic regression\": LogisticRegression(max_iter=1000),\r\n    \"random forest\": RandomForestClassifier(random_state=21),\r\n}\r\n\r\nfor name, m in models.items():\r\n    print(f\"{name}: {cross_val_score(m, X, y, cv=5).mean():.3f}\")<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">baseline (most frequent): 0.503\r\nlogistic regression: 0.918\r\nrandom forest: 0.929<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q32. How do you pick an evaluation metric for a business problem?<\/b><\/strong><\/h3>\n<p>Ask what each kind of mistake costs. If missing a positive case is expensive, as in fraud or disease screening, focus on recall. If false alarms are expensive, focus on precision. For ranking quality use ROC AUC or the precision recall curve, and for forecasts use an error measure such as MAE in business units.<\/p>\n<h3><strong><b>Q33. How do you know a model is overfitting, and what do you do about it?<\/b><\/strong><\/h3>\n<p>Compare training performance with validation performance. If training is much better, the model is memorising the data. Use cross validation, simplify the model, add regularisation, reduce noisy features or get more data. Also check for data leakage, which can make a model look better than it is.<\/p>\n<h3><strong><b>Q34. How do you explain a model prediction to a business user?<\/b><\/strong><\/h3>\n<p>Use plain language and a concrete example. Show the few factors that pushed the prediction up or down, using coefficients for linear models or permutation importance and SHAP values for complex ones. Tell them how reliable the model is and where it should not be trusted, instead of showing technical metrics alone.<\/p>\n<h2><strong><b>A B Testing and Experimentation (Intermediate and Experienced)<\/b><\/strong><\/h2>\n<p>Experiment design is one of the most common areas where interviewers separate strong candidates from average ones. Product and e commerce companies in particular spend a lot of time on it.<\/p>\n<h3><strong><b>Q35. What is an A B test, and how do you analyse one?<\/b><\/strong><\/h3>\n<p>An A B test randomly splits users into a control group that sees the current version and a treatment group that sees the change, then compares a chosen metric between them. For a conversion rate, use a two proportion z test or a chi square test, and report the difference, its confidence interval and the p value.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\nfrom scipy.stats import norm\r\n\r\ncontrol_n, control_conv = 5000, 400       # 8.0 percent\r\ntreat_n, treat_conv = 5000, 460           # 9.2 percent\r\n\r\np1, p2 = control_conv \/ control_n, treat_conv \/ treat_n\r\npooled = (control_conv + treat_conv) \/ (control_n + treat_n)\r\nse = np.sqrt(pooled * (1 - pooled) * (1 \/ control_n + 1 \/ treat_n))\r\nz = (p2 - p1) \/ se\r\np_value = 2 * (1 - norm.cdf(abs(z)))\r\n\r\nprint(f\"lift: {p2 - p1:.3%}  z: {z:.2f}  p value: {p_value:.4f}\")<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">lift: 1.200%  z: 2.14  p value: 0.0323<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q36. How do you decide the sample size for an A B test?<\/b><\/strong><\/h3>\n<p>Fix the baseline rate, the smallest effect worth detecting, the significance level and the power before you start. A common approximation for a conversion rate with 5 percent significance and 80 percent power is about 16 times p times (1 minus p), divided by the squared difference, users per group. Smaller effects need far more users.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">from scipy.stats import norm\r\n\r\ndef users_per_group(baseline, lift, alpha=0.05, power=0.80):\r\n    p1, p2 = baseline, baseline + lift\r\n    z_alpha, z_beta = norm.ppf(1 - alpha \/ 2), norm.ppf(power)\r\n    variance = p1 * (1 - p1) + p2 * (1 - p2)\r\n    return (z_alpha + z_beta) ** 2 * variance \/ lift ** 2\r\n\r\nprint(round(users_per_group(0.08, 0.01)))\r\nprint(round(users_per_group(0.08, 0.005)))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">12205\r\n47525<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The quick rule gives a slightly lower number than this exact formula. Halving the effect you want to detect roughly quadruples the number of users you need. That is why tiny improvements can take weeks to confirm.<\/p>\n<h3><strong><b>Q37. What is sample ratio mismatch?<\/b><\/strong><\/h3>\n<p>Sample ratio mismatch means the number of users in each group differs from the split you planned, for example 50 to 50, by more than chance allows. It signals a bug in assignment or logging, and the results are not trustworthy until it is fixed. Check it with a chi square test on the group counts.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">from scipy.stats import chisquare\r\n\r\nobserved = [5200, 4800]                  # planned split was 50 to 50\r\nexpected = [5000, 5000]\r\n\r\nstat, p = chisquare(observed, expected)\r\nprint(\"p value:\", p)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">p value: 6.334248366623988e-05<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q38. What is the peeking problem in A B testing?<\/b><\/strong><\/h3>\n<p>Peeking means checking the results repeatedly and stopping as soon as the p value drops below 0.05. Each look is another chance for a false positive, so the real error rate becomes much higher than 5 percent. Decide the sample size in advance and wait for it, or use sequential testing methods designed for repeated looks.<\/p>\n<h3><strong><b>Q39. How do you handle multiple comparisons?<\/b><\/strong><\/h3>\n<p>Testing many metrics or segments at once raises the chance that at least one looks significant by luck. Control it by naming one primary metric in advance, and by adjusting the threshold for the others, for example with the Bonferroni correction, which divides alpha by the number of tests, or the Benjamini Hochberg method.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">alpha, tests = 0.05, 20\r\n\r\nprint(\"chance of at least one false positive with no correction:\", round(1 - (1 - alpha) ** tests, 2))\r\nprint(\"Bonferroni threshold per test:\", alpha \/ tests)<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">chance of at least one false positive with no correction: 0.64\r\nBonferroni threshold per test: 0.0025<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><strong><b>Q40. What are primary and guardrail metrics?<\/b><\/strong><\/h3>\n<p>The primary metric is the single measure that decides whether the experiment succeeded, such as conversion rate. Guardrail metrics are measures that must not get worse, such as page load time, refund rate or unsubscribe rate. A change that lifts the primary metric but breaks a guardrail should not ship.<\/p>\n<h3><strong><b>Q41. What can you do when you cannot run a randomised A B test?<\/b><\/strong><\/h3>\n<p>Use a quasi experimental method. A difference in differences design compares the change over time in a treated group with the change in a similar untreated group. Matching, synthetic control and regression with careful controls are other options. All of them rely on assumptions, so state the assumptions and the limits of the conclusion.<\/p>\n<h2><strong><b>Case Study Questions (Experienced)<\/b><\/strong><\/h2>\n<p>Case questions are open on purpose. The interviewer wants to see how you structure a vague problem, what you ask first and how you reach a recommendation. Say your steps aloud, and state assumptions as you go.<\/p>\n<h3><strong><b>Q42. Daily orders on a food delivery app dropped 15 percent last week. How do you investigate?<\/b><\/strong><\/h3>\n<p>First confirm that the drop is real by checking data pipelines and tracking, then compare it with the same week in earlier periods. Break the drop down by city, platform, customer type, restaurant and time, find which segment explains most of it, and test the likely causes for that segment, such as an outage, a price change, a competitor offer or supply shortage.<\/p>\n<ul>\n<li>Check data first: late loads, broken events and app releases that changed tracking.<\/li>\n<li>Compare against last week, the same week last year and any holiday effect.<\/li>\n<li>Split by city, app version, new versus returning users, restaurant and hour of day.<\/li>\n<li>Look at the funnel: app opens, searches, cart, payment and delivery, to see where users drop.<\/li>\n<li>Rank the explanations by how much of the drop they explain, then propose a fix and a way to confirm it.<\/li>\n<\/ul>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import pandas as pd\r\n\r\ndata = pd.DataFrame({\r\n    \"segment\": [\"Pune Android\", \"Pune iOS\", \"Bangalore Android\", \"Bangalore iOS\"],\r\n    \"last_week\": [4000, 2500, 5000, 3000],\r\n    \"this_week\": [3950, 2480, 2880, 2970],\r\n})\r\n\r\ndata[\"change\"] = data[\"this_week\"] - data[\"last_week\"]\r\ndata[\"share_of_drop\"] = (data[\"change\"] \/ data[\"change\"].sum()).round(2)\r\n\r\nprint(data.to_string(index=False))\r\nprint(\"total change:\", data[\"change\"].sum())<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">          segment  last_week  this_week  change  share_of_drop\r\n     Pune Android       4000       3950     -50           0.02\r\n         Pune iOS       2500       2480     -20           0.01\r\nBangalore Android       5000       2880   -2120           0.95\r\n    Bangalore iOS       3000       2970     -30           0.01\r\ntotal change: -2220<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>In this made up table, one segment explains most of the total decline, so that is where the investigation should go next.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You check the data before the business, you segment to find where the problem is, and you finish with a testable explanation.<\/i><\/em><\/p>\n<h3><strong><b>Q43. How would you build a churn prediction model for a subscription business?<\/b><\/strong><\/h3>\n<p>Start by defining churn, the prediction window and the action the business will take. Build features from past behaviour such as usage, payments and support contacts, using only data available at the prediction date. Split by time, compare against a simple baseline, choose a metric that matches the cost of a retention offer, and plan how the scores will be used and monitored.<\/p>\n<ul>\n<li>Define churn precisely, for example no activity for 30 days, and the horizon to predict, for example the next 30 days.<\/li>\n<li>Build features as of the prediction date only, to avoid leakage.<\/li>\n<li>Split the data by time so the test period comes after the training period.<\/li>\n<li>Pick a metric and threshold from the cost of an offer and the value of a retained customer.<\/li>\n<li>Deliver a ranked list or score to the retention team, and measure whether the offers actually reduce churn.<\/li>\n<\/ul>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You start from the decision and the data timeline, not from the algorithm.<\/i><\/em><\/p>\n<h3><strong><b>Q44. How would you measure the success of a new feature?<\/b><\/strong><\/h3>\n<p>Link the feature to a business goal, choose one primary metric, add guardrail metrics, and run a randomised experiment if you can. Define the target group, the minimum change worth detecting and the test duration in advance. After the test, look at segments to see who benefits, and decide whether the gain justifies the cost of running the feature.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You use an experiment, one clear primary metric and guardrails against harm.<\/i><\/em><\/p>\n<h3><strong><b>Q45. You need to forecast demand for 500 products. How do you start?<\/b><\/strong><\/h3>\n<p>Start with simple baselines, such as the last value, the same period last year and a moving average, and measure them on a time based holdout. Group products by pattern, since stable, seasonal and intermittent items need different methods. Add a more advanced model only if it beats the baseline by enough to matter, and report forecast error in business units.<\/p>\n<div style=\"margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px; overflow: hidden;\">\n<div style=\"background: #0f2a4a; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">code<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #f5f8fc; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">import numpy as np\r\n\r\nrng = np.random.default_rng(5)\r\nweeks = np.arange(104)\r\ndemand = 200 + 30 * np.sin(2 * np.pi * weeks \/ 52) + rng.normal(0, 8, 104)\r\n\r\ntrain, test = demand[:78], demand[78:]\r\nnaive = np.full(len(test), train[-1])                    # repeat the last value\r\nseasonal = demand[78 - 52: 104 - 52]                     # same week last year\r\nmoving_avg = np.full(len(test), train[-4:].mean())       # average of last 4 weeks\r\n\r\ndef mae(pred): return round(float(np.abs(pred - test).mean()), 1)\r\n\r\nprint(\"naive:\", mae(naive), \"| seasonal naive:\", mae(seasonal), \"| moving average:\", mae(moving_avg))<\/pre>\n<div style=\"background: #1f2937; color: #ffffff; font-family: Arial,Helvetica,sans-serif; font-size: 14px; font-weight: bold; padding: 8px 16px;\">output<\/div>\n<pre style=\"margin: 0; padding: 16px; background: #ffffff; color: #1f2937; font-family: 'Courier New',Courier,monospace; font-size: 14px; line-height: 1.7; overflow-x: auto; white-space: pre;\">naive: 16.6 | seasonal naive: 7.1 | moving average: 25.5<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>On data with a yearly pattern, the seasonal baseline wins easily. Any complex model has to beat it to earn its place.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You build and respect baselines, validate on later data, and judge a model by business error.<\/i><\/em><\/p>\n<h2><strong><b>Project and Behavioural Questions (All Levels)<\/b><\/strong><\/h2>\n<p>Interviewers use these questions to find out how you work with people, handle imperfect data and take ownership. Use real examples from your own projects, and prepare them in advance.<\/p>\n<h3><strong><b>Q46. Walk me through a data science project you worked on.<\/b><\/strong><\/h3>\n<p>Tell it in five parts: the business problem, the data you had, what you did and why, the result with a number, and what you would change. Keep your own contribution clear, and be ready for questions on any choice you made. Choose a project you can explain in about three minutes.<\/p>\n<ul>\n<li>Problem: who needed what decision, and why it mattered.<\/li>\n<li>Data: sources, size, quality issues and how you handled them.<\/li>\n<li>Approach: baseline, the model you chose and why, and how you validated it.<\/li>\n<li>Result: the measured outcome and how the business used it.<\/li>\n<li>Reflection: one thing you would do differently.<\/li>\n<\/ul>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>Clear ownership, honest numbers and the ability to defend each decision.<\/i><\/em><\/p>\n<h3><strong><b>Q47. Tell me about a time you worked with messy or incomplete data.<\/b><\/strong><\/h3>\n<p>Pick a real case and describe the specific problems, such as missing values, inconsistent categories or duplicate records. Explain how you found them, what you decided and why, and what effect your choices had on the result. Mention that you documented your assumptions so others could review them.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You check data before trusting it, and you can explain trade offs.<\/i><\/em><\/p>\n<h3><strong><b>Q48. How do you present findings to a non technical audience?<\/b><\/strong><\/h3>\n<p>Start with the decision or answer, then give the two or three facts that support it, using simple charts and plain words. Leave out method detail unless asked, state the uncertainty honestly, and end with a clear recommendation and next step. Check afterwards that the audience understood what to do.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You lead with the answer and adapt the message to the listener.<\/i><\/em><\/p>\n<h3><strong><b>Q49. What would you do if stakeholders disagree with your analysis?<\/b><\/strong><\/h3>\n<p>Listen first to understand what they disagree with, then check whether they know something you missed. Show your data and method openly, test their point where possible, and agree on how to resolve it, for example with an additional cut of the data or an experiment. Be willing to change your view if the evidence supports it.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You stay open to being wrong and settle disagreements with evidence.<\/i><\/em><\/p>\n<h3><strong><b>Q50. Describe a mistake you made in an analysis and what you changed afterwards.<\/b><\/strong><\/h3>\n<p>Choose a real, modest mistake, state it plainly, say how you found it and how you told the people affected. Then explain the specific process change you made, such as a review step, a data check or a test, so it would not happen again. Interviewers value honesty and learning over a perfect record.<\/p>\n<p><strong><b>What the interviewer is listening for: <\/b><\/strong><em><i>You take responsibility without excuses and you improved a process.<\/i><\/em><\/p>\n<h2><strong><b>Common questions about data science interviews<\/b><\/strong><\/h2>\n<h3><strong><b>What do data science interviews usually include?<\/b><\/strong><\/h3>\n<p>Most data science interviews have a screening call, a SQL or Python test, a statistics and machine learning round, a case study or take home task, and a conversation about your past projects. Product companies add experimentation questions, and larger teams add a system design or deployment round.<\/p>\n<h3><strong><b>How should a fresher prepare for a data science interview?<\/b><\/strong><\/h3>\n<p>Learn SQL and pandas well, because they decide most first rounds. Then revise statistics basics, one end to end machine learning project and how to explain it. Practise answering aloud. Having two projects you can defend in detail counts for more than a long list of tools.<\/p>\n<h3><strong><b>Is SQL really necessary for data science?<\/b><\/strong><\/h3>\n<p>Yes. Almost every data science role needs you to pull and join your own data, and many first round tests are SQL only. You should be comfortable with joins, grouping, window functions and common table expressions, and able to explain what each query does and why.<\/p>\n<h3><strong><b>How is a data science interview different from a data analyst interview?<\/b><\/strong><\/h3>\n<p>Analyst interviews lean toward SQL, dashboards and business metrics. Data science interviews add statistics, experiment design and machine learning, and expect you to build and validate models. The two overlap heavily at junior level, so read the job description for the exact weight.<\/p>\n<h3><strong><b>How many projects should I have ready for an interview?<\/b><\/strong><\/h3>\n<p>Prepare two or three projects that you can explain from the business problem to the result. Choose ones where you made real decisions about data, modelling and evaluation. Be honest about what you did yourself, and be ready to discuss what went wrong and what you would change.<\/p>\n<h2><strong><b>A four week plan to prepare<\/b><\/strong><\/h2>\n<p>Use this plan if you have about a month before your interview.<\/p>\n<div style=\"border: 1px solid #d9e0ea; border-radius: 8px; overflow-x: auto; margin: 20px 0; -webkit-overflow-scrolling: touch;\">\n<table style=\"width: 100%; min-width: 640px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.6; color: #1f2937;\">\n<caption style=\"caption-side: top; text-align: left; padding: 14px 16px; font-weight: bold; font-size: 17px; color: #0f2a4a;\">Four week study plan<\/caption>\n<thead>\n<tr>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 90px;\" scope=\"col\">Week<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38; width: 260px;\" scope=\"col\">Focus<\/th>\n<th style=\"background: #0f2a4a; color: #ffffff; text-align: left; padding: 12px 16px; border-bottom: 2px solid #0b1f38;\" scope=\"col\">What to do<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Week 1<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">SQL: joins, grouping, window functions and CTEs<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Run every SQL example in this guide, then write ten of your own queries on a sample database.<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Week 2<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Python, pandas and exploratory analysis<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Take one public dataset, clean it and write down five findings. Practise the pandas section.<\/td>\n<\/tr>\n<tr style=\"background: #ffffff;\">\n<th style=\"text-align: left; padding: 12px 16px; border-bottom: 1px solid #e5e9f0; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Week 3<\/th>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Statistics, machine learning and A B testing<\/td>\n<td style=\"padding: 12px 16px; border-bottom: 1px solid #e5e9f0;\">Work through the statistics and experiment sections, then build one baseline model end to end.<\/td>\n<\/tr>\n<tr style=\"background: #f5f8fc;\">\n<th style=\"text-align: left; padding: 12px 16px; color: #0f2a4a; white-space: nowrap;\" scope=\"row\">Week 4<\/th>\n<td style=\"padding: 12px 16px;\">Case studies, projects and mock interviews<\/td>\n<td style=\"padding: 12px 16px;\">Practise two case questions aloud, write your three minute project story and take a mock interview.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><strong><b>Practise with a trainer<\/b><\/strong><\/h2>\n<p>If you want to practise these questions with a trainer and build projects you can talk about in interviews, you can book a free demo class for the Prwatech Data Science course. It covers Python, SQL, statistics and machine learning with hands on work.<\/p>\n<p>Contact the learning team for current batch dates and fees.<\/p>\n<p>Written by Mithun Ray, data engineering trainer at Prwatech. Reviewed by Avishekh Verma. Last updated October,2026.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Data Science Interview Questions and Answers Data science interviews have changed. A few years ago most of the questions were definitions of statistics terms. Today employers test whether you can get data with SQL, clean and explore it in pandas, reason about statistics and experiments, build a sensible model, and explain the result to people [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3465,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1709,36],"tags":[85],"class_list":["post-3462","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interview-questions-interview-questions","category-interview-questions","tag-data-science-interview-questions-and-answers"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>50 Data Science Interview Questions and Answers | PrwaTech<\/title>\n<meta name=\"description\" content=\"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"50 Data Science Interview Questions and Answers | PrwaTech\" \/>\n<meta property=\"og:description\" content=\"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-12T06:37:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-13T02:52:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"550\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/\",\"url\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/\",\"name\":\"50 Data Science Interview Questions and Answers | PrwaTech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg\",\"datePublished\":\"2026-10-12T06:37:59+00:00\",\"dateModified\":\"2026-10-13T02:52:15+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg\",\"width\":960,\"height\":550,\"caption\":\"Data Science Interview Questions and Answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Top 50 Data Science Interview Questions and Answers with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"50 Data Science Interview Questions and Answers | PrwaTech","description":"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"50 Data Science Interview Questions and Answers | PrwaTech","og_description":"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers","og_url":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-10-12T06:37:59+00:00","article_modified_time":"2026-10-13T02:52:15+00:00","og_image":[{"width":960,"height":550,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg","type":"image\/jpeg"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/","url":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/","name":"50 Data Science Interview Questions and Answers | PrwaTech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg","datePublished":"2026-10-12T06:37:59+00:00","dateModified":"2026-10-13T02:52:15+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Data science interview questions with answers on SQL, pandas, statistics, A - B testing and case studies. For freshers and experienced. top questions and answers","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2019\/11\/Data-Science-Interview-Questions-and-Answers.jpg","width":960,"height":550,"caption":"Data Science Interview Questions and Answers"},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/interview-questions\/data-science-interview-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Top 50 Data Science Interview Questions and Answers with Examples"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/3462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=3462"}],"version-history":[{"count":8,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/3462\/revisions"}],"predecessor-version":[{"id":11968,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/3462\/revisions\/11968"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media\/3465"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=3462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=3462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=3462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}