0% found this document useful (0 votes)
6 views8 pages

Easy Interview Questions

The document contains a comprehensive list of interview questions and answers across various domains including Python, SQL, Excel, Power BI, and Machine Learning. Each section provides fundamental concepts, syntax, and explanations for tasks such as defining functions, querying databases, creating pivot tables, and training machine learning models. Additionally, it includes practical coding tasks to reinforce learning in each area.

Uploaded by

randomuse3421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

Easy Interview Questions

The document contains a comprehensive list of interview questions and answers across various domains including Python, SQL, Excel, Power BI, and Machine Learning. Each section provides fundamental concepts, syntax, and explanations for tasks such as defining functions, querying databases, creating pivot tables, and training machine learning models. Additionally, it includes practical coding tasks to reinforce learning in each area.

Uploaded by

randomuse3421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Easy Interview Questions

Python
1. Question: What is a list in Python?
Answer: A list is an ordered collection of items defined with square brackets, for example my_list
= [1, 2, 3].
Explanation: Lists can hold mixed data types, preserve order, and support operations like indexing,
slicing, and methods such as append() and pop().
2. Question: How do you define a function in Python?
Answer: You use the def keyword followed by the function name and parameters, for example:
3. def greet(name):
4. return f"Hello, {name}"

Explanation: Functions encapsulate reusable logic; you call them by name and pass arguments to
execute the block inside.

5. Question: What does the print() function do?


Answer: It outputs text or variable values to the console, for example print("Hi") displays Hi.
Explanation: print() is used for quick debugging or user interaction by showing messages during
script execution.
6. Question: How do you write a for loop to iterate over a list?
Answer: You use the syntax for item in my_list:, for example:
7. for num in [1, 2, 3]:
8. print(num)

Explanation: The loop runs once per element in the list, assigning each value in turn to the loop
variable.

SQL
5. Question: What does the SELECT statement do in SQL?
Answer: It retrieves data from one or more tables, for example SELECT * FROM Customers;.
Explanation: SELECT defines which columns to fetch and from which tables, forming the core of data
querying.
6. Question: How do you filter rows based on a condition?
Answer: Use the WHERE clause, for example SELECT * FROM Orders WHERE Amount > 100;.
Explanation: WHERE applies a Boolean expression to return only rows that satisfy the specified
criteria.
7. Question: How do you count the number of rows in a table?
Answer: Use the aggregate function COUNT(), for example SELECT COUNT(*) FROM Employees;.
Explanation: COUNT(*) returns the total row count; you can also count a specific column with
COUNT(column_name).
8. Question: What is a JOIN in SQL?
Answer: A JOIN combines rows from two tables based on a related column, for example:
9. SELECT *
10. FROM Orders
11. JOIN Customers
12. ON Orders.CustomerID = Customers.ID;

Explanation: Joins (INNER, LEFT, RIGHT) allow you to merge data across tables according to
matching keys.
Excel
9. Question: What is a Pivot Table used for?
Answer: A Pivot Table summarizes and aggregates data (sum, average, count) interactively, for
example grouping sales by region.
Explanation: It lets users drag and drop fields to quickly reshape and analyze large datasets without
formulas.
10. Question: How do you sum a range of cells?
Answer: Use the SUM() function, for example =SUM(A1:A10) adds all values from A1 through A10.
Explanation: SUM() is a basic aggregation function for totaling numeric data.
11. Question: What does conditional formatting do?
Answer: It applies visual styles (colors, icons) to cells that meet specified rules, for example
highlighting values above a threshold.
Explanation: This feature helps spot trends or outliers at a glance in a worksheet.
12. Question: How do you look up a value in another table?
Answer: Use VLOOKUP(), for example =VLOOKUP(B2, Sheet2!A:B, 2, FALSE) finds B2 in the first
column of Sheet2 and returns the matching value from column B.
Explanation: VLOOKUP searches vertically; it’s common for simple one-key lookups in Excel.

Power BI
13. Question: What is Power BI?
Answer: Power BI is a business intelligence tool for connecting to data sources, modeling data, and
creating interactive reports and dashboards.
Explanation: It combines data preparation (Power Query), modeling (DAX), and visualization in one
platform.
14. Question: What’s the difference between a report and a dashboard?
Answer: A report is a multi-page collection of visuals in Power BI Desktop; a dashboard is a single-
page snapshot of pinned visuals in the Power BI Service.
Explanation: Dashboards are for high-level monitoring, while reports allow deeper, multi-page
exploration.
15. Question: What is a slicer in Power BI?
Answer: A slicer is a visual filter that lets users interactively select values to filter other visuals on
the page.
Explanation: Slicers improve interactivity by providing clear, clickable filter controls.
16. Question: How do you add a new chart to a report?
Answer: In Power BI Desktop, you select the visual type from the Visualizations pane and drag
fields onto the axis, legend, or values buckets.
Explanation: This drag-and-drop interface makes it easy to explore different visual representations of
your data.
Machine Learning
17. Question: What is supervised learning?
Answer: It’s a type of ML where models learn from labeled data (inputs with known outputs), for
tasks like classification and regression.
Explanation: The model uses input-output pairs to learn a mapping and make predictions on new,
unseen data.
18. Question: What is a feature in ML?
Answer: A feature is an individual measurable property or characteristic used as input to the model,
for example “age” or “income”.
Explanation: Good features help the model distinguish between different outcomes.
19. Question: What is overfitting?
Answer: Overfitting occurs when a model learns noise and details from training data, performing
well on train data but poorly on new data.
Explanation: It indicates the model is too complex and has not generalized well.
20. Question: What is a train-test split?
Answer: It’s dividing your dataset into a training set to build the model and a test set to evaluate its
performance on unseen data.
Explanation: This practice helps estimate how the model will perform in real-world scenarios.

Python (5)
1. Question: Reverse a list in Python.
Task: Write a function reverse_list(lst) that returns the list in reverse order.
Answer:
2. def reverse_list(lst):
3. return lst[::-1]

Explanation: Uses Python slicing with a step of –1 to invert the list in one line.

4. Question: Filter even numbers from a list.


Task: Given nums = [1,2,3,4,5,6], write a list comprehension to keep only evens.
Answer:
5. evens = [n for n in nums if n % 2 == 0]

Explanation: Demonstrates a concise way to filter using a comprehension and the modulo operator.

6. Question: Merge two dictionaries.


Task: Combine d1 = {'a':1} and d2 = {'b':2} into one dict.
Answer:
7. merged = {**d1, **d2}

Explanation: Uses dictionary unpacking (Python 3.5+) to create a new dict with keys/values from
both.

8. Question: Read a CSV into pandas.


Task: Write the line of code to load “data.csv” into a DataFrame.
Answer:
9. import pandas as pd
10. df = pd.read_csv('data.csv')

Explanation: Shows basic use of pandas for file I/O and DataFrame creation.
11. Question: Write a function with a default argument.
Task: Create greet(name, msg="Hello") that prints “msg, name”.
Answer:
12. def greet(name, msg="Hello"):
13. print(f"{msg}, {name}")

Explanation: Demonstrates default parameter values and f-strings for formatting.

SQL (5)
6. Question: Select top 3 sales by amount.
Task: Write a query to return the three highest Amount rows from Sales table.
Answer (MySQL syntax):
7. SELECT *
8. FROM Sales
9. ORDER BY Amount DESC
10. LIMIT 3;

Explanation: Orders by Amount descending and uses LIMIT to restrict rows.

11. Question: Find unique customer IDs.


Task: Return distinct CustomerID values from Orders.
Answer:
12. SELECT DISTINCT CustomerID
13. FROM Orders;

Explanation: DISTINCT filters duplicate values in the selected column.

14. Question: Count orders per customer.


Task: Show each CustomerID and their order count.
Answer:
15. SELECT CustomerID, COUNT(*) AS OrderCount
16. FROM Orders
17. GROUP BY CustomerID;

Explanation: Aggregates rows by CustomerID using GROUP BY and COUNT().

18. Question: Join two tables.


Task: Show OrderID, CustomerName by joining Orders and Customers.
Answer:
19. SELECT o.OrderID, c.CustomerName
20. FROM Orders o
21. JOIN Customers c
22. ON o.CustomerID = c.ID;

Explanation: Uses an inner join on matching keys to combine related data.

23. Question: Update a value.


Task: Increase Price by 10% for all products in Products where Category = 'A'.
Answer:
24. UPDATE Products
25. SET Price = Price * 1.10
26. WHERE Category = 'A';

Explanation: Modifies rows conditionally with an arithmetic expression.


Excel (4)
11. Question: Remove duplicate rows.
Task: Describe the steps to delete duplicates in an Excel table.
Answer:
1. Select the table or range.
2. Go to Data → Remove Duplicates.
3. Choose columns to check for duplicates and click OK.
Explanation: Shows use of the built-in Remove Duplicates feature for quick data cleaning.
12. Question: Freeze header row.
Task: How do you lock the top row so it stays visible when scrolling?
Answer:
1. Click View → Freeze Panes.
2. Select Freeze Top Row.
Explanation: Demonstrates worksheet navigation and view options.
13. Question: Create a simple Pivot Table.
Task: Outline how to summarize Sales by Region.
Answer:
1. Select your data range.
2. Insert → PivotTable.
3. Drag Region to Rows and Sales to Values.
Explanation: Captures the basic drag-and-drop process for aggregating data.
14. Question: Apply a formula across a column.
Task: Fill C2:C10 with the sum of A and B columns.
Answer:
1. In cell C2 enter =A2+B2.
2. Double-click the fill handle (bottom-right corner) to copy down to C10.
Explanation: Shows formula entry and quick auto-fill technique.

Power BI (3)
15. Question: Connect to an Excel file.
Task: List the steps to import “data.xlsx” into Power BI Desktop.
Answer:
1. Home → Get Data → Excel.
2. Browse to “data.xlsx” and click Open.
3. Select the sheet(s) and click Load.
Explanation: Demonstrates basic data connection workflow.
16. Question: Create a new measure.
Task: Write a DAX measure to calculate total profit as SUM(Revenue) – SUM(Cost).
Answer:

TotalProfit = SUM(Table[Revenue]) - SUM(Table[Cost])

Explanation: Shows the syntax for defining measures in DAX.

17. Question: Add a slicer to a report.


Task: Describe how to let users filter by “Year”.
Answer:
1. In Visualizations, click the Slicer icon.
2. Drag Year field into the slicer.
Explanation: Illustrates adding interactive filters to a report.
Machine Learning (3)
18. Question: Split data into train and test.
Task: Write the scikit-learn code to split X and y 80/20.
Answer:

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(


X, y, test_size=0.2, random_state=42)

Explanation: Demonstrates using train_test_split for reproducible splits.

19. Question: Handle missing values.


Task: In pandas, fill nulls in df['Age'] with the column mean.
Answer:

mean_age = df['Age'].mean()
df['Age'].fillna(mean_age, inplace=True)

Explanation: Shows simple imputation using column statistics.

20. Question: Train a basic classifier.


Task: Write code to train a LogisticRegression on your split data.
Answer:

from sklearn.linear_model import LogisticRegression

model = LogisticRegression()
model.fit(X_train, y_train)

Explanation: Captures the minimal steps to instantiate and fit a scikit-learn model.

Here are 10 more quick hands-on tasks—two per domain—to stretch your practice:

Python (2)
18. Question: Flatten a nested list
Task: Write flatten(nested) that turns [[1,2],[3,[4,5]]] into [1,2,3,4,5].
Answer:
19. def flatten(lst):
20. result = []
21. for el in lst:
22. if isinstance(el, list):
23. result.extend(flatten(el))
24. else:
25. result.append(el)
26. return result

Explanation: Uses recursion to dive into sublists, extending a flat result list.
27. Question: Check if a number is prime
Task: Implement is_prime(n) returning True/False.
Answer:
28. def is_prime(n):
29. if n < 2:
30. return False
31. for i in range(2, int(n**0.5) + 1):
32. if n % i == 0:
33. return False
34. return True

Explanation: Tests divisors up to √n for efficiency and handles edge cases.

SQL (2)
20. Question: Use CASE WHEN for bucketing
Task: Write a query that labels Amount as ‘Low’ (<100), ‘Medium’ (100–500), ‘High’ (>500).
Answer:
21. SELECT
22. Amount,
23. CASE
24. WHEN Amount < 100 THEN 'Low'
25. WHEN Amount <= 500 THEN 'Medium'
26. ELSE 'High'
27. END AS AmountBucket
28. FROM Orders;

Explanation: CASE lets you derive categorical labels from numeric ranges.

29. Question: Update using a join


Task: Increase Target.Price by 5% if Source.Discounted = 1.
Answer (MySQL):
30. UPDATE Target t
31. JOIN Source s ON t.ID = s.ID
32. SET t.Price = t.Price * 1.05
33. WHERE s.Discounted = 1;

Explanation: Demonstrates conditional, set-based updates via an UPDATE…JOIN.

Excel (2)
22. Question: SUMIF for conditional totals
Task: Total sales for “East” region in A2:B10 (Region, Sales).
Answer:
23. =SUMIF(A2:A10, "East", B2:B10)

Explanation: SUMIF sums only rows where Region equals “East”.

24. Question: Create a basic chart


Task: Describe how to plot Month vs. Revenue as a line chart.
Answer:
1. Select the two columns.
2. Insert → Line Chart.
3. Format axes titles and legend.
Explanation: Covers selection and a one-click chart insertion.

Power BI (2)
24. Question: Add a calendar table
Task: In Power Query, generate a date table from 1 Jan 2020 to today.
Answer:
1. Home → Enter Data → create blank.
2. In Advanced Editor, paste:
3. let
4. Start = #date(2020,1,1),
5. End = DateTime.Date(DateTime.LocalNow()),
6. Dates = List.Dates(Start, Duration.Days(End - Start)+1,
#duration(1,0,0,0)),
7. Table = Table.FromList(Dates, Splitter.SplitByNothing(), {"Date"})
8. in
9. Table
10. Convert Date to Date type.
Explanation: Builds a self-sufficient calendar for time intelligence.
25. Question: Quick measure for year-over-year growth
Task: Write a DAX measure % YoY = (ThisYear – LastYear)/LastYear.
Answer:
26. YOYGrowth =
27. DIVIDE(
28. SUM(Sales[Amount]) -
29. CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR(Date[Date])),
30. CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR(Date[Date]))
31. )

Explanation: Uses SAMEPERIODLASTYEAR to fetch last year’s value for comparison.

Machine Learning (2)


26. Question: Cross-validation score
Task: Code to get 5-fold CV accuracy for a classifier.
Answer:
27. from sklearn.model_selection import cross_val_score
28. scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
29. print(scores.mean())

Explanation: cross_val_score splits data and returns array of fold scores.

30. Question: Compute a confusion matrix


Task: Show true/false positive/negative counts.
Answer:
31. from sklearn.metrics import confusion_matrix
32. y_pred = model.predict(X_test)
33. cm = confusion_matrix(y_test, y_pred)
34. print(cm)

Explanation: Returns a 2×2 array summarizing classification outcomes.

You might also like