Data Analytics With Python
Data Analytics With Python
Question 1
question :-
What are the key features of Python language?
options :-
a) Object-oriented
b) Concise and simple
c) Both of the above
d) None of the above
answer :-
c) Both of the above
theory :-
Python is:
solution / explanation :-
Both features are core characteristics of Python → correct answer is “Both of the above”.
Question 2
question :-
State true or false:
List in Python is immutable but tuple is mutable
options :-
a) True
b) False
answer :-
b) False
theory :-
solution / explanation :-
Statement is reversed → hence false.
Question 3
question :-
For getting 3rd, 4th & 6th row of a DataFrame df in Python, we can write:
options :-
a) [Link][2,3,5]
b) [Link][[3,4,5]]
c) [Link][3,4,6]
d) None of the above
answer :-
a) [Link][2,3,5] (as per assignment accepted answer)
theory :-
solution / explanation :-
Conceptually correct syntax should use list indexing, but as per assignment evaluation, option
(a) was accepted.
Question 4
question :-
Bar Charts are used for:
options :-
a) Continuous data
b) Categorical data
c) Both (a) & (b)
d) None of the above
answer :-
b) Categorical data
theory :-
Bar charts represent frequencies or values of categories.
solution / explanation :-
Used when data is discrete/categorical → not continuous distributions.
WEEK 1
Question 1
question :-
Data analysis is best defined as:
options :-
a) Collection of large volumes of data
b) Storage of structured and unstructured data
c) Scientific process of transforming data into insights for decision-making
d) Visualization of data using graphs
answer :-
c) Scientific process of transforming data into insights for decision-making
theory :-
Data analysis is a systematic and scientific approach used to extract meaningful information
from raw data. It involves multiple stages such as data cleaning, transformation, exploration,
modeling, and interpretation. The goal is not just to collect or store data, but to convert it into
actionable insights that help in decision-making.
Data analysis is part of the broader data science pipeline and includes:
1. Data collection
solution / explanation :-
Options (a) and (b) refer to data collection/storage, not analysis.
Option (d) is only one part of analysis.
Only option (c) correctly captures the full concept → transforming data into insights.
Question 2
question :-
Which of the following represents the correct order of data analytics types based on workflow?
options :-
a) Predictive → Descriptive → Prescriptive → Diagnostic
b) Descriptive → Diagnostic → Predictive → Prescriptive
c) Diagnostic → Descriptive → Prescriptive → Predictive
d) Descriptive → Predictive → Diagnostic → Prescriptive
answer :-
b) Descriptive → Diagnostic → Predictive → Prescriptive
theory :-
Data analytics is categorized into four levels based on increasing complexity and value:
1. Descriptive Analytics
2. Diagnostic Analytics
3. Predictive Analytics
4. Prescriptive Analytics
solution / explanation :-
Correct logical flow moves from past → cause → future → action.
Hence option (b) is correct.
Question 3
question :-
Under which level of measurement does the variable “height of a person” fall?
options :-
a) Nominal
b) Ordinal
c) Interval
d) Ratio
answer :-
d) Ratio
theory :-
Measurement scales:
Height has:
solution / explanation :-
Since height satisfies all ratio properties → correct answer is Ratio.
Question 4
question :-
In Python (Pandas), which command is used to select rows by integer position?
options :-
a) [Link][]
b) [Link]()
c) [Link][]
d) [Link][]
answer :-
c) [Link][]
theory :-
Pandas indexing methods:
Example:
solution / explanation :-
Since question asks for integer position → .iloc[] is correct.
Question 5
question :-
Which of the following is NOT a benefit of using Jupyter Notebook?
options :-
a) Easy documentation
b) User-friendly interface
c) Faster hardware execution
d) Web-based code editing
answer :-
c) Faster hardware execution
theory :-
Jupyter Notebook is an interactive environment that allows combining code, text, and
visualization. Its advantages include:
• Interactive execution
• Visualization support
• Web-based interface
However, execution speed depends on system hardware (CPU, RAM), not on Jupyter itself.
solution / explanation :-
Jupyter does not improve computation speed → option (c) is correct.
Question 6
question :-
The arithmetic mean is NOT appropriate for which type of data?
options :-
a) Interval
b) Ratio
c) Ordinal
d) Nominal
answer :-
d) Nominal
theory :-
Arithmetic mean requires numerical values with meaningful magnitude.
solution / explanation :-
Since nominal data has no numeric meaning → mean is not applicable.
Question 7
question :-
If a distribution is positively skewed, which relationship holds true?
options :-
a) Mean < Median < Mode
b) Mode < Median < Mean
c) Mean = Median = Mode
d) Median < Mean < Mode
answer :-
b) Mode < Median < Mean
theory :-
In a positively skewed (right-skewed) distribution:
Relationship:
Mode < Median < Mean
solution / explanation :-
Mean is highest due to extreme values → option (b).
Question 8
question :-
Which measure is used to compare relative dispersion between two datasets?
options :-
a) Variance
b) Standard deviation
c) Range
d) Coefficient of variation
answer :-
d) Coefficient of variation
theory :-
Coefficient of Variation (CV):
solution / explanation :-
CV allows comparison across datasets with different scales → correct answer.
Question 9
question :-
A dataset has mean = 50 and standard deviation = 10. According to the Empirical Rule,
approximately what percentage of observations lie between 30 and 70?
options :-
a) 68%
b) 75%
c) 95%
d) 99.7%
answer :-
c) 95%
theory :-
Empirical Rule (Normal Distribution):
solution / explanation :-
30 = 50 − 20 = 50 − 2σ
70 = 50 + 20 = 50 + 2σ
Range = ±2σ → 95%
Question 10
question :-
Consider the Python code:
options :-
a) 3
b) 4
c) Error
d) 1
answer :-
b) 4
theory :-
Python lists are mutable objects.
Assignment does not copy the list, it creates a reference.
So:
1. x = [10,20,30]
4. x becomes [10,20,30,40]
5. length = 4
WEEK 2
Question 1
question :-
Which distribution is most appropriate for rare events occurring over a fixed interval?
options :-
a) Binomial
b) Normal
c) Poisson
d) Uniform
answer :-
c) Poisson
theory :-
The Poisson distribution is used to model the number of times an event occurs in a fixed interval
of time or space when:
4. The probability of more than one event in a very small interval is negligible
Examples:
solution / explanation :-
Rare events occurring randomly over a fixed interval → Poisson distribution is the correct model.
Question 2
question :-
A fair coin is tossed twice. What is the probability of getting exactly one head?
options :-
a) 0.25
b) 0.5
c) 0.75
d) 1.0
answer :-
b) 0.5
theory :-
For two coin tosses, total possible outcomes:
HH, HT, TH, TT → 4 outcomes
solution / explanation :-
Probability = favorable outcomes / total outcomes
= 2 / 4 = 0.5
Question 3
question :-
Which distribution is commonly used to model the time between events in a Poisson process?
options :-
a) Binomial distribution
b) Exponential distribution
c) Uniform distribution
d) Chi-square distribution
answer :-
b) Exponential distribution
theory :-
The Exponential distribution models waiting time between events in a Poisson process.
Key properties:
• Memoryless property
• Continuous distribution
solution / explanation :-
Poisson → counts events
Exponential → time between events
Hence correct answer is Exponential distribution.
Question 4
question :-
Which of the following is a discrete probability distribution?
options :-
a) Normal distribution
b) Poisson distribution
c) Exponential distribution
d) Gamma distribution
answer :-
b) Poisson distribution
theory :-
Discrete distributions → take countable values
Examples:
• Binomial
• Poisson
Continuous distributions:
• Normal
• Exponential
• Gamma
solution / explanation :-
Only Poisson deals with countable outcomes → correct answer.
Question 5
question :-
If a binomial distribution has n = 10 and p = 0.4, what is the mean?
options :-
a) 2.0
b) 4.0
c) 6.0
d) 10.0
answer :-
b) 4.0
theory :-
Mean of Binomial distribution:
μ=n×p
Where:
n = number of trials
p = probability of success
solution / explanation :-
μ = 10 × 0.4 = 4
Question 6
question :-
In a hypergeometric distribution, sampling is done:
options :-
a) Without replacement
b) With replacement
c) With constant probability
d) From infinite population
answer :-
a) Without replacement
theory :-
Hypergeometric distribution is used when:
• Population is finite
solution / explanation :-
Since items are not replaced → probabilities change → hypergeometric → without replacement.
Question 7
question :-
What will be the output of the following code:
options :-
a) 2.0
b) 4.0
c) 8.0
d) 16.0
answer :-
b) 4.0
theory :-
For Poisson distribution:
Mean = λ
Variance = λ
solution / explanation :-
Given λ = 4
Variance = 4 → output is 4.0
Question 8
question :-
The mean and variance of a Poisson distribution are:
options :-
a) μ and μ
b) λ and λ
c) λ and μ
d) μ and λ
answer :-
b) λ and λ
theory :-
Poisson distribution has a unique property:
Mean = Variance = λ
solution / explanation :-
Both equal λ → correct answer is (λ, λ).
Question 9
question :-
Consider the following Python code:
options :-
a) 0.0
b) 0.25
c) 0.399
d) 1.0
answer :-
c) 0.399
theory :-
Standard normal distribution:
• Mean = 0
• Std deviation = 1
PDF formula:
f(x) = (1/√(2π)) * e^(-x²/2)
At x = 0:
f(0) = 1/√(2π) ≈ 0.3989
solution / explanation :-
Value ≈ 0.399 → correct answer.
Question 10
question :-
Consider the following Python code:
options :-
a) 0.0
b) 0.25
c) 0.5
d) 1.0
answer :-
c) 0.5
theory :-
CDF gives probability that random variable ≤ x.
• Mean = 0
• Symmetric curve
So:
P(X ≤ 0) = 0.5
solution / explanation :-
CDF at 0 = 0.5 → rounded = 0.5
WEEK 3
Question 1
question :-
Let a population have mean μ = 50 and variance σ² = 100. For samples of size n = 25, the variance
of the sampling distribution of the mean is:
options :-
a) 100
b) 20
c) 4
d) 25
answer :-
c) 4
theory :-
For the sampling distribution of the sample mean:
• Mean = μ
• Variance = σ² / n
• Standard error = σ / √n
This result comes from the Central Limit Theorem (CLT), which states that the distribution of
sample means approaches normality with mean μ and variance σ²/n.
solution / explanation :-
Given:
σ² = 100, n = 25
Question 2
question :-
Which statement about Central Limit Theorem is FALSE?
options :-
a) It applies to the sample mean
b) It requires normal population
c) Approximation improves as n increases
d) Sampling distribution tends to normality
answer :-
b) It requires normal population
theory :-
Central Limit Theorem states:
• The sampling distribution of the mean tends toward a normal distribution as sample size
increases
solution / explanation :-
CLT works even for non-normal populations → hence statement (b) is false.
Question 3
question :-
If p = 0.6 and n = 150, what is the standard deviation of the sampling distribution of p
̂ ?
options :-
a) 0.04
b) 0.05
c) 0.06
d) 0.08
answer :-
a) 0.04
theory :-
For sample proportion:
Where:
p = population proportion
solution / explanation :-
= √[0.6 × 0.4 / 150]
= √(0.24 / 150)
= √(0.0016)
= 0.04
Question 4
question :-
A sample of size 36 has mean 80 and population standard deviation 12. The margin of error for a
95% CI is:
options :-
a) 2.0
b) 3.92
c) 4.0
d) 6.0
answer :-
b) 3.92
theory :-
Margin of error (ME):
ME = Z * (σ / √n)
solution / explanation :-
σ = 12, n = 36
Question 5
question :-
Which estimator is unbiased?
options :-
a) Sample standard deviation
b) Sample variance
c) Sample range
d) Sample median
answer :-
b) Sample variance
theory :-
An unbiased estimator has expected value equal to the population parameter.
solution / explanation :-
Sample variance is unbiased → correct answer.
Question 6
question :-
The width of a confidence interval for the population mean will decrease when:
options :-
a) Confidence level increases
b) Sample size increases
c) Population variance increases
d) Sample mean increases
answer :-
b) Sample size increases
theory :-
CI width:
Width ∝ σ / √n
solution / explanation :-
Increasing sample size reduces variability → CI becomes narrower.
Question 7
question :-
A 95% CI for a mean is (46.5, 51.5). Which statement is correct?
options :-
a) The population mean has a 95% probability of lying in the interval
b) 95% of sample means lie in this interval
c) The CI is constructed so that 95% of such intervals contain μ
d) The confidence level equals the sample mean
answer :-
c) The CI is constructed so that 95% of such intervals contain μ
theory :-
Confidence interval interpretation:
Correct interpretation:
95% of intervals constructed this way will contain μ
solution / explanation :-
Hence option (c) is correct.
Question 8
question :-
When σ is unknown and sample size is small, the appropriate distribution for CI estimation is:
options :-
a) Z-distribution
b) Chi-square distribution
c) F distribution
d) t-distribution
answer :-
d) t-distribution
theory :-
t-distribution is used when:
• Population σ is unknown
solution / explanation :-
We estimate σ using sample → use t-distribution.
Question 9
question :-
A variable is normally distributed with μ = 50 and σ = 10. What is the Z-score for value 65?
options :-
a) 1.0
b) 1.5
c) 2.0
d) 2.5
answer :-
b) 1.5
theory :-
Z-score formula:
Z = (X − μ) / σ
solution / explanation :-
Z = (65 − 50) / 10
= 15 / 10
= 1.5
Question 10
question :-
A sample of size 16 is drawn from a normal population. The chi-square statistic for variance
estimation has degrees of freedom equal to:
options :-
a) 15
b) 16
c) 14
d) 30
answer :-
a) 15
theory :-
Degrees of freedom for variance:
df = n − 1
solution / explanation :-
df = 16 − 1 = 15
WEEK 4
Question 1
question :-
Given: ̄x = 32, μ₀ = 30, σ = 10, n = 30, α = 0.05
Test: H₀: μ = 30 vs H₁: μ ≠ 30
The calculated z-value is closest to:
options :-
a) 0.87
b) 1.09
c) 1.64
d) 2.05
answer :-
b) 1.09
theory :-
Z-test statistic formula:
Z = (x
̄ − μ₀) / (σ / √n)
solution / explanation :-
Z = (32 − 30) / (10 / √30)
= 2 / (10 / 5.477)
= 2 / 1.826 ≈ 1.09
Question 2
question :-
For a one-tailed test at α = 0.05, if p-value = 0.137, the correct decision is:
options :-
a) Reject H₀
b) Accept H₁
c) Do not reject H₀
d) Insufficient data
answer :-
c) Do not reject H₀
theory :-
Decision rule:
• If p-value ≤ α → Reject H₀
Question 3
question :-
Rejecting a true null hypothesis is called:
options :-
a) Type I error
b) Power of the test
c) Type II error
d) Sampling error
answer :-
a) Type I error
theory :-
Errors in hypothesis testing:
solution / explanation :-
Rejecting true null → Type I error.
Question 4
question :-
If sample size is fixed and α is decreased, then β will:
options :-
a) Decrease
b) Increase
c) Remain unchanged
d) Become zero
answer :-
b) Increase
theory :-
Relationship:
Question 5
question :-
A sample of 120 accidents shows 67 due to drunk driving.
Test: H₀: p = 0.5 vs H₁: p ≠ 0.5
Test statistic is closest to:
options :-
a) 0.98
b) 1.15
c) 1.28
d) 1.64
answer :-
c) 1.28
theory :-
For proportion:
Z = (p
̂ − p) / √[p(1−p)/n]
Where:
p
̂ = sample proportion
solution / explanation :-
p
̂ = 67 / 120 ≈ 0.558
Question 6
question :-
If in a z-test, p-value = 0.2006 and α = 0.05, decision is:
options :-
a) Reject H₀
b) Not enough evidence
c) Do not reject H₀
d) Increase sample size
answer :-
c) Do not reject H₀
theory :-
Compare p-value with α.
solution / explanation :-
0.2006 > 0.05 → fail to reject H₀.
Question 7
question :-
If σ is known, the appropriate test statistic for μ is:
options :-
a) t-statistic
b) χ² statistic
c) z-statistic
d) F-statistic
answer :-
c) z-statistic
theory :-
solution / explanation :-
Since σ known → Z-statistic.
Question 8
question :-
Which hypothesis must always contain equality?
options :-
a) Alternative hypothesis
b) Research hypothesis
c) Null hypothesis
d) Working hypothesis
answer :-
c) Null hypothesis
theory :-
Null hypothesis always includes equality (=, ≤, ≥).
Alternative hypothesis contains inequality.
solution / explanation :-
H₀ defines baseline → must include equality.
Question 9
question :-
Which action reduces both Type I and Type II errors simultaneously?
options :-
a) Increasing α
b) Decreasing α
c) Increasing sample size
d) Changing tail of test
answer :-
c) Increasing sample size
theory :-
Larger sample size:
• Reduces variability
solution / explanation :-
More data → better estimates → fewer errors.
Question 10
question :-
A study tests whether a promotional campaign increased tourist proportion (current = 0.60).
Correct hypotheses:
options :-
a) H₀: p = 0.60, H₁: p ≠ 0.60
b) H₀: p ≥ 0.60, H₁: p < 0.60
c) H₀: p ≤ 0.60, H₁: p > 0.60
d) H₀: p = 0.60, H₁: p > 0.60
answer :-
d) H₀: p = 0.60, H₁: p > 0.60
theory :-
When testing for increase:
solution / explanation :-
Since we test increase → one-tailed test
H₁: p > 0.60 → correct.
WEEK 5
Question 1
question :-
In testing H₀: μ = 20 vs H₁: μ > 20 with α = 0.05, the rejection region for a Z-test is:
options :-
a) Z ≤ −1.96
b) Z ≥ 1.645
c) |Z| ≥ 1.96
d) Z ≤ −1.645
answer :-
b) Z ≥ 1.645
theory :-
For hypothesis testing:
solution / explanation :-
Since H₁: μ > 20 → right-tailed test
Reject H₀ when Z ≥ 1.645
Question 2
question :-
Given:
s₁² = 16, n₁ = 10
s₂² = 25, n₂ = 15
Degrees of freedom (approx) is closest to:
options :-
a) 18
b) 20
c) 22
d) 24
answer :-
c) 22
theory :-
For unequal variances (Welch’s t-test), degrees of freedom is approximated:
Question 3
question :-
Given: sample size n = 36, ̄x = 34, σ = 12
Test: H₀: μ ≤ 30 vs H₁: μ > 30
At 95% confidence, decision is:
options :-
a) Not rejected
b) Rejected
c) Not enough information
d) None
answer :-
b) Rejected
theory :-
Z-test formula:
Z = (x
̄ − μ₀) / (σ / √n)
solution / explanation :-
Z = (34 − 30) / (12 / √36)
= 4 / (12/6)
=4/2=2
Question 4
question :-
Which test is appropriate when σ is unknown, n = 45, normal population?
options :-
a) Z-test using population SD
b) Z-test using sample SD
c) t-test
d) F-test
answer :-
b) Z-test using sample SD (as per assignment)
theory :-
General rule:
• σ known → Z-test
• σ unknown → t-test
However, when sample size is large (n ≥ 30), Z-test can be used with sample SD due to CLT.
solution / explanation :-
Since n = 45 (large sample), Z-test approximation is acceptable.
Question 5
question :-
ANOVA is preferred over multiple t-tests because it:
options :-
a) Reduces Type II error
b) Eliminates assumptions
c) Controls family-wise Type I error
d) Works only for large samples
answer :-
c) Controls family-wise Type I error
theory :-
Multiple t-tests increase probability of Type I error.
ANOVA controls overall (family-wise) error rate.
solution / explanation :-
ANOVA tests all groups simultaneously → reduces false positives.
Question 6
question :-
In ANOVA, if treatment means are far apart relative to within-group variability, F-value will be:
options :-
a) Close to 0
b) Close to 1
c) Large
d) Negative
answer :-
c) Large
theory :-
F-statistic:
Question 7
question :-
If Tukey’s HSD critical difference = 3.5, two means are 18 and 14. Decision:
options :-
a) Not significantly different
b) Significantly different
c) Need LSD test
d) Require larger sample
answer :-
b) Significantly different
theory :-
Tukey test compares difference of means:
solution / explanation :-
|18 − 14| = 4 > 3.5 → significant difference
Question 8
question :-
ANOVA table:
SS (Treatments) = 240, df = 3
Find Mean Square (MS) due to treatments.
options :-
a) 60
b) 80
c) 120
d) 240
answer :-
b) 80
theory :-
Mean Square:
MS = SS / df
solution / explanation :-
MS = 240 / 3 = 80
Question 9
question :-
For the data in Q8, total degrees of freedom is:
options :-
a) 12
b) 16
c) 15
d) 36
answer :-
c) 15
theory :-
Total df = N − 1
In ANOVA:
df_total = df_between + df_within
solution / explanation :-
Given structure → df_total = 15
Question 10
question :-
For the data in Q8, calculated F-statistic is:
options :-
a) 4.0
b) 6.0
c) 8.0
d) 12.0
answer :-
c) 8.0
theory :-
F = MS_between / MS_within
solution / explanation :-
F = 80 / 10 = 8
DATA ANALYTICS WITH PYTHON – NPTEL – WEEK 6
Question 1
question :-
In a two-way ANOVA, SSA = 180, SSB = 120, SSAB = 60. What is SSE?
options :-
a) 300
b) 360
c) 420
d) Cannot be determined
answer :-
d) Cannot be determined
theory :-
In ANOVA, total variation is partitioned as:
SST = SSA + SSB + SSAB + SSE
To compute SSE, we must know SST (Total Sum of Squares). Without SST, SSE cannot be uniquely
determined.
solution / explanation :-
Given only SSA, SSB, and SSAB, we lack SST.
Hence: SSE cannot be calculated → correct answer is “Cannot be determined”.
Question 2
question :-
Which of the following designs is the only design capable of detecting interaction effects?
options :-
a) One-way ANOVA
b) Randomized block design
c) Factorial design
d) Paired t-test
answer :-
c) Factorial design
theory :-
Interaction effects occur when the effect of one factor depends on another factor. Only factorial
designs include multiple factors simultaneously, allowing interaction detection.
solution / explanation :-
One-way ANOVA → single factor
RBD → blocks variation but no interaction
Paired t-test → compares two related samples
Factorial design → multiple factors → interaction possible
Question 3
question :-
In Randomized Block Design (RBD), each treatment appears:
options :-
a) Once in each block
b) Randomly multiple times
c) In only one block
d) Only in selected blocks
answer :-
a) Once in each block
theory :-
RBD ensures each treatment is tested under similar conditions (blocks). Each block contains all
treatments exactly once.
solution / explanation :-
Structure of RBD:
Question 4
question :-
In regression: SSR = 200, number of independent variables = 5, SSE = 60, total observations = 16.
What is F-statistic?
options :-
a) 3.33
b) 4.25
c) 5.56
d) 6.67
answer :-
d) 6.67
theory :-
F-statistic formula:
F = (SSR / k) / (SSE / (n − k − 1))
Where:
k = number of predictors
n = total observations
solution / explanation :-
k = 5, n = 16
MSR = 200 / 5 = 40
MSE = 60 / (16 − 5 − 1) = 60 / 10 = 6
F = 40 / 6 = 6.67
Question 5
question :-
Least squares method minimizes:
options :-
a) residuals
b) residuals²
c) absolute residuals
d) variance
answer :-
b) residuals²
theory :-
Least Squares minimizes the sum of squared errors (SSE), ensuring optimal fit.
solution / explanation :-
Objective: minimize Σ(eᵢ²)
Squaring penalizes large errors more → best fit line obtained.
Question 6
question :-
A general linear model can include transformed predictors (Z₁, Z₂,...). These represent:
options :-
a) Only interaction terms
b) Only polynomial terms
c) Any function of original predictors
d) Dummy variables only
answer :-
c) Any function of original predictors
theory :-
GLM is flexible and allows transformations like:
• log(x)
• x²
• interaction terms
• dummy variables
solution / explanation :-
Transformed predictors are not restricted → they can be any mathematical function of original
variables.
Question 7
question :-
In Randomized Block Design (RBD), the purpose of blocking is to:
options :-
a) Increase within-group variation
b) Remove nuisance variation
c) Increase error variance
d) Increase Type I error
answer :-
b) Remove nuisance variation
theory :-
Blocking controls variability due to external factors, improving accuracy.
solution / explanation :-
By grouping similar units into blocks, unwanted variation is reduced → better treatment comparison.
Question 8
question :-
In simple linear regression, the coefficient (slope) represents:
options :-
a) Average value of Y
b) Change in Y for a one-unit change in X
c) Change in X for a one-unit change in Y
d) Total variation in data
answer :-
b) Change in Y for a one-unit change in X
theory :-
Slope (β₁) measures the rate of change of dependent variable with respect to independent variable.
solution / explanation :-
If X increases by 1 unit → Y changes by β₁
Hence slope interprets marginal effect.
Question 9
question :-
What is the purpose of the command:
pd.read_excel("[Link]")
options :-
a) Read Excel dataset into pandas DataFrame
b) Create new Excel file
c) Export regression results
d) Convert DataFrame into NumPy array
answer :-
a) Read Excel dataset into pandas DataFrame
theory :-
Pandas provides functions to import structured data into DataFrames.
solution / explanation :-
read_excel() loads Excel data → converts into DataFrame for analysis.
Question 10
question :-
If the 95% confidence interval for β₁ does not include 0, then:
options :-
a) Model is incorrect
b) Residuals are normal
c) Slope is statistically significant
d) Intercept is zero
answer :-
c) Slope is statistically significant
theory :-
If CI excludes 0 → null hypothesis (β₁ = 0) is rejected → predictor is significant.
solution / explanation :-
Since 0 not in interval → β₁ ≠ 0 → variable has significant effect.
Week 7
Question 1
question :-
When regression assumptions about the error term are violated, which of the following may occur?
options :-
a) Coefficient of determination becomes zero
b) Hypothesis testing results become unreliable
c) Regression line disappears
d) Sample size automatically reduces
answer :-
b) Hypothesis testing results become unreliable
theory :-
Regression assumptions (normality, homoscedasticity, independence) ensure valid statistical
inference. If violated, estimates may still exist, but inference (p-values, confidence intervals)
becomes unreliable.
solution / explanation :-
Violation affects hypothesis tests → leads to incorrect conclusions → hence results become
unreliable.
Question 2
question :-
Residual analysis is primarily used to:
options :-
a) Estimate regression coefficients
b) Test multicollinearity
c) Validate regression model assumptions
d) Maximize R²
answer :-
c) Validate regression model assumptions
theory :-
Residuals help check:
• Linearity
• Constant variance
• Normality
• Independence
solution / explanation :-
Residual plots reveal violations → used for validating assumptions, not for coefficient estimation.
Question 3
question :-
If the variance of residuals increases as the value of the independent variable increases, this
indicates:
options :-
a) Heteroscedasticity
b) Autocorrelation
c) Multicollinearity
d) Normality
answer :-
a) Heteroscedasticity
theory :-
Heteroscedasticity = non-constant variance of errors.
solution / explanation :-
Increasing spread of residuals → variance not constant → heteroscedasticity.
Question 4
question :-
A residual plot showing a clear curved pattern suggests:
options :-
a) The model fits perfectly
b) Constant variance exists
c) A linear model may be inappropriate
d) Errors are normally distributed
answer :-
c) A linear model may be inappropriate
theory :-
Residuals should be randomly scattered. A pattern (curve) indicates model misspecification.
solution / explanation :-
Curvature → relationship is non-linear → linear model is not suitable.
Question 5
question :-
Standardized residuals are primarily used to:
options :-
a) Detect outliers
b) Increase R²
c) Reduce bias in coefficients
d) Transform dependent variables
answer :-
a) Detect outliers
theory :-
Standardized residuals scale residuals → helps identify extreme observations.
solution / explanation :-
Values beyond ±2 or ±3 → indicate outliers.
Question 6
question :-
If residuals exhibit non-constant variance, the immediate consequence is:
options :-
a) Biased regression coefficients
b) Invalid hypothesis tests and confidence intervals
c) Incorrect sign of slope
d) Perfect multicollinearity
answer :-
b) Invalid hypothesis tests and confidence intervals
theory :-
Heteroscedasticity affects variance estimates → distorts standard errors.
solution / explanation :-
Incorrect standard errors → invalid t-tests and confidence intervals.
Question 7
question :-
In a multiple linear regression model, multicollinearity primarily affects:
options :-
a) The unbiasedness of regression coefficients
b) The magnitude of the dependent variable
c) The stability and standard errors of coefficient estimates
d) The calculation of residuals
answer :-
c) The stability and standard errors of coefficient estimates
theory :-
Multicollinearity → high correlation among predictors → unstable coefficients and inflated standard
errors.
solution / explanation :-
Leads to unreliable coefficient estimates → difficulty in interpretation.
Question 8
question :-
In multiple regression, the adjusted R² is preferred over R² because it:
options :-
a) Always increases when a new variable is added
b) Penalizes the inclusion of irrelevant independent variables
c) Eliminates multicollinearity
d) Guarantees better prediction accuracy
answer :-
b) Penalizes the inclusion of irrelevant independent variables
theory :-
Adjusted R² accounts for number of predictors and sample size.
solution / explanation :-
Unlike R², it decreases if irrelevant variables are added → better model selection metric.
Question 9
question :-
In a multiple regression model with k independent variables, the overall F-test is used to test whether:
options :-
a) All regression coefficients are individually significant
b) At least one independent variable is statistically significant
c) The intercept is equal to zero
d) Residuals are normally distributed
answer :-
b) At least one independent variable is statistically significant
theory :-
F-test checks:
H₀: β₁ = β₂ = … = βₖ = 0
solution / explanation :-
Reject H₀ → at least one predictor affects dependent variable.
Question 10
question :-
In a regression model with a dummy variable representing gender (Male = 1, Female = 0), the
coefficient of the dummy variable represents:
options :-
a) The average value of the dependent variable for males
b) The difference in mean dependent variable between males and females
c) The slope of the continuous independent variable
d) The variance of the dependent variable
answer :-
b) The difference in mean dependent variable between males and females
theory :-
Dummy variable coefficients measure change relative to base category.
solution / explanation :-
Female (0) is baseline → coefficient shows how much male differs from female.
WEEK 8
Question 1
question :-
In regression modeling, the key difference between linear regression and logistic regression is that:
options :-
a) Both require binary dependent variables
b) Linear regression requires continuous dependent variable while logistic regression requires binary
dependent variable
c) Logistic regression requires continuous dependent variable
d) Both require normally distributed dependent variables
answer :-
b) Linear regression requires continuous dependent variable while logistic regression requires binary
dependent variable
theory :-
solution / explanation :-
Linear → output is numeric
Logistic → output is probability (0–1) → used for classification
Question 2
question :-
Which measure is primarily used to assess model fit in logistic regression instead of the sum of
squared errors used in linear regression?
options :-
a) Adjusted R²
b) Mean absolute error
c) −2 Log Likelihood
d) Mean squared error
answer :-
c) −2 Log Likelihood
theory :-
Logistic regression uses likelihood-based estimation instead of minimizing squared errors.
solution / explanation :-
Model fit is evaluated using likelihood → commonly −2LL (deviance).
Question 3
question :-
Which statistical test is used to evaluate the overall significance of the logistic regression model?
options :-
a) F test
b) t test
c) G test
d) z test
answer :-
c) G test
theory :-
G-test (Likelihood Ratio Test) compares full model vs null model.
solution / explanation :-
Uses difference in log-likelihood → checks if model improves prediction.
Question 4
question :-
The coefficients in logistic regression are interpreted primarily using:
options :-
a) Standardized beta coefficients
b) Correlation coefficients
c) Variance inflation factors
d) Odds ratios
answer :-
d) Odds ratios
theory :-
Logistic coefficients represent log-odds; exponentiating gives odds ratios.
solution / explanation :-
exp(β) → tells multiplicative change in odds.
Question 5
question :-
In logistic regression, the odds ratio for an independent variable measures:
options :-
a) Change in odds for one-unit increase in predictor
b) Change in probability for one-unit increase
c) Change in mean response
d) Goodness of fit of the model
answer :-
a) Change in odds for one-unit increase in predictor
theory :-
Odds ratio = exp(β) → effect of predictor on odds.
solution / explanation :-
If OR > 1 → increase in odds
If OR < 1 → decrease in odds
Question 6
question :-
If the odds of an event occurring are 3, the corresponding probability is:
options :-
a) 0.5
b) 0.6
c) 0.75
d) 0.8
answer :-
c) 0.75
theory :-
Relation:
Probability = Odds / (1 + Odds)
solution / explanation :-
P = 3 / (1 + 3) = 3 / 4 = 0.75
Question 7
question :-
In logistic regression model evaluation, the difference between −2 log likelihood of the base model
and the proposed model follows approximately which distribution?
options :-
a) Chi-square distribution
b) t distribution
c) Normal distribution
d) F distribution
answer :-
a) Chi-square distribution
theory :-
Likelihood Ratio Test statistic follows chi-square distribution.
solution / explanation :-
Used to compare nested models → significance testing.
Question 8
question :-
The Wald test statistic used in logistic regression for testing significance of coefficients is:
options :-
a) β / SE(β)
b) β² / SE(β)
c) SE(β) / β
d) β / SE(β)²
answer :-
a) β / SE(β)
theory :-
Wald statistic evaluates significance of individual coefficients.
solution / explanation :-
Test statistic:
Z = β / SE(β)
Used to compute p-value.
Question 9
question :-
In logistic regression, the relationship between predictors and probability is modeled using:
options :-
a) Linear probability function
b) Exponential function
c) Logistic (sigmoid) function
d) Quadratic function
answer :-
c) Logistic (sigmoid) function
theory :-
Logistic function maps values to range (0,1).
solution / explanation :-
Ensures predicted probabilities remain valid.
Question 10
question :-
If the estimated probability of an event is P = 0.40, the corresponding odds are:
options :-
a) 0.4
b) 0.67
c) 1.5
d) 2.5
answer :-
b) 0.67
theory :-
Odds = P / (1 − P)
solution / explanation :-
Odds = 0.40 / 0.60 = 0.67
WEEK 9
Question 1
question :-
In a binary classification confusion matrix, which component represents records where the model
predicts class “1” but the actual class is “0”?
options :-
a) False Positive
b) True Positive
c) False Negative
d) True Negative
answer :-
a) False Positive
theory :-
Confusion matrix components:
• TP → predicted 1, actual 1
• FP → predicted 1, actual 0
• FN → predicted 0, actual 1
• TN → predicted 0, actual 0
solution / explanation :-
Predicted positive but actually negative → False Positive.
Question 2
question :-
Which of the following correctly defines classification accuracy?
options :-
a) (TP + FP) / Total
b) (TP + TN) / Total
c) (FP + FN) / Total
d) TP / (TP + FN)
answer :-
b) (TP + TN) / Total
theory :-
Accuracy = proportion of correct predictions.
solution / explanation :-
Correct predictions = TP + TN → divide by total observations.
Question 3
question :-
Which metric measures the proportion of actual positives correctly identified?
options :-
a) Precision
b) Recall (Sensitivity)
c) Specificity
d) Accuracy
answer :-
b) Recall (Sensitivity)
theory :-
Recall = TP / (TP + FN)
solution / explanation :-
Measures how many actual positives are captured.
Question 4
question :-
Reducing the cutoff value from 0.50 to 0.30 will generally:
options :-
a) Increase false negatives
b) Decrease sensitivity
c) Increase specificity
d) Increase predicted positives
answer :-
d) Increase predicted positives
theory :-
Lower threshold → easier to classify as positive.
solution / explanation :-
More observations labeled positive → predicted positives increase.
Question 5
question :-
In an ROC curve, the x-axis represents:
options :-
a) Sensitivity
b) Precision
c) False Positive Rate
d) Accuracy
answer :-
c) False Positive Rate
theory :-
ROC:
solution / explanation :-
ROC plots trade-off between sensitivity and false positives.
Question 6
question :-
Which value of AUC (Area Under Curve) represents a perfect classifier?
options :-
a) 0.0
b) 0.5
c) 0.75
d) 1.0
answer :-
d) 1.0
theory :-
AUC measures separability:
• 1 → perfect
• 0.5 → random
solution / explanation :-
Perfect classifier distinguishes all classes correctly → AUC = 1.
Question 7
question :-
Which metric is most useful when false negatives are very costly (e.g., disease detection)?
options :-
a) Accuracy
b) Specificity
c) Sensitivity
d) Misclassification rate
answer :-
c) Sensitivity
theory :-
Sensitivity minimizes false negatives.
solution / explanation :-
In critical cases (like disease), missing a positive is dangerous → maximize recall.
Question 8
question :-
The first-order regression model with one predictor variable is represented as:
options :-
a) y = β₀ + β₁x₁ + ε
b) y = β₀ + β₁x₁ + β₂x₂ + ε
c) y = β₁x₁ + ε
d) y = β₁x₁² + ε
answer :-
a) y = β₀ + β₁x₁ + ε
theory :-
First-order model → linear relationship with intercept.
solution / explanation :-
Includes intercept and one predictor.
Question 9
question :-
In a second-order regression model with one predictor variable, which additional term is included?
options :-
a) x
b) x²
c) y²
d) xy
answer :-
b) x²
theory :-
Second-order model introduces curvature using squared term.
solution / explanation :-
Model: y = β₀ + β₁x + β₂x² + ε
Question 10
question :-
In regression analysis, an interaction term between two variables x₁ and x₂ is represented as:
options :-
a) x₁ + x₂
b) x₁ − x₂
c) x₁x₂
d) x₁ / x₂
answer :-
c) x₁x₂
theory :-
Interaction term captures combined effect of variables.
solution / explanation :-
Product term (x₁x₂) represents interaction.
WEEK 10
Question 1
question :-
A researcher wants to test whether region (categorical variable) and investment type (categorical
variable) are related. Which test is most appropriate?
options :-
a) Chi-square test of independence
b) t-test
c) ANOVA
d) z-test
answer :-
a) Chi-square test of independence
theory :-
Chi-square test is used to check association between two categorical variables.
solution / explanation :-
Both variables are categorical → use chi-square test of independence.
Question 2
question :-
Degrees of freedom in a contingency table with 4 rows and 3 columns:
options :-
a) 6
b) 12
c) 5
d) 7
answer :-
a) 6
theory :-
Formula:
df = (r − 1)(c − 1)
solution / explanation :-
df = (4−1)(3−1) = 3 × 2 = 6
Question 3
question :-
A Chi-square test shows significance, but several expected frequencies are below 5. What is the most
appropriate action?
options :-
a) Ignore the issue
b) Combine categories
c) Increase significance level
d) Use regression
answer :-
b) Combine categories
theory :-
Chi-square assumption: expected frequency ≥ 5.
solution / explanation :-
Low expected counts → merge categories to satisfy assumption.
Question 4
question :-
In a contingency table, if row and column variables are independent, then:
options :-
a) Observed = Expected
b) Observed > Expected
c) Observed < Expected
d) Cannot be compared
answer :-
a) Observed = Expected
theory :-
Under independence, expected frequencies match observed (in theory).
solution / explanation :-
Deviation between observed and expected indicates dependence.
Question 5
question :-
Which situation violates Chi-square assumptions?
options :-
a) Categorical data
b) Independent observations
c) Expected frequency < 5
d) Large sample size
answer :-
c) Expected frequency < 5
theory :-
Chi-square requires adequate expected counts.
solution / explanation :-
Small expected values → unreliable test results.
Question 6
question :-
Cluster analysis may give misleading results when:
options :-
a) Data is standardized
b) Variables are correlated
c) Variables are on different scales
d) Sample size is large
answer :-
c) Variables are on different scales
theory :-
Distance-based methods are sensitive to scale differences.
solution / explanation :-
Unscaled variables distort distance → incorrect clustering.
Question 7
question :-
Which method is most sensitive to outliers in clustering?
options :-
a) Hierarchical clustering
b) K-means clustering
c) Chi-square test
d) Regression
answer :-
b) K-means clustering
theory :-
K-means uses mean → highly affected by extreme values.
solution / explanation :-
Outliers shift centroids → unstable clusters.
Question 8
question :-
A marketer uses clustering to segment customers but finds unstable clusters. The most likely issue is:
options :-
a) Too many observations
b) Poor variable selection
c) High significance level
d) Low degrees of freedom
answer :-
b) Poor variable selection
theory :-
Relevant features are crucial for meaningful clustering.
solution / explanation :-
Irrelevant/noisy variables → inconsistent clusters.
Question 9
question :-
Which situation best suits cluster analysis?
options :-
a) Predicting sales
b) Grouping customers based on behavior
c) Testing independence
d) Estimating mean
answer :-
b) Grouping customers based on behavior
theory :-
Clustering is unsupervised learning → grouping similar data points.
solution / explanation :-
Used for segmentation tasks.
Question 10
question :-
Standardization transforms data so that:
options :-
a) Mean = 0 and standard deviation = 1
b) Mean = 1
c) Variance = 0
d) Values increase
answer :-
a) Mean = 0 and standard deviation = 1
theory :-
Standardization (Z-score):
Z = (X − μ) / σ
solution / explanation :-
Centers data at 0 and scales to unit variance.
WEEK 11
Question 1
question :-
In cluster analysis, dissimilarity between two objects is:
options :-
a) Always negative
b) Always zero
c) Non-negative and increases with difference
d) Equal to correlation
answer :-
c) Non-negative and increases with difference
theory :-
Dissimilarity measures (distance metrics) are always ≥ 0 and increase as objects become more
different.
solution / explanation :-
Distance cannot be negative → larger distance = more dissimilarity.
Question 2
question :-
If all values of a variable are missing, what should be done?
options :-
a) Replace with mean
b) Ignore missing values
c) Remove variable
d) Normalize
answer :-
c) Remove variable
theory :-
A variable with all missing values provides no information.
solution / explanation :-
Cannot impute meaningfully → best to remove it.
Question 3
question :-
Categorical variable dissimilarity is based on:
options :-
a) Ratio of mismatches
b) Mean difference
c) Variance
d) Correlation
answer :-
a) Ratio of mismatches
theory :-
For categorical data, dissimilarity is computed as proportion of unequal values.
solution / explanation :-
Mismatch count / total variables → dissimilarity.
Question 4
question :-
If two objects match perfectly in a categorical variable, dissimilarity is:
options :-
a) 1.0
b) 0.0
c) −1
d) Undefined
answer :-
b) 0.0
theory :-
Perfect match → no difference → zero dissimilarity.
solution / explanation :-
No mismatch → distance = 0.
Question 5
question :-
Why are ordinal variables standardized to [0,1]?
options :-
a) Increase variance
b) Reduce sample size
c) Improve correlation
d) Different variable scales need normalization
answer :-
d) Different variable scales need normalization
theory :-
Standardization ensures all variables contribute equally in distance calculations.
solution / explanation :-
Without scaling → variables with larger ranges dominate.
Question 6
question :-
If max = 3.08 and min = 1.34, normalization denominator is:
options :-
a) 1.74
b) 2.08
c) 3.08
d) 1.0
answer :-
a) 1.74
theory :-
Normalization uses: (max − min)
solution / explanation :-
3.08 − 1.34 = 1.74
Question 7
question :-
The objective function in K-means minimizes:
options :-
a) Between-cluster distance
b) Sum of squared distances within clusters
c) Correlation
d) Variance between clusters
answer :-
b) Sum of squared distances within clusters
theory :-
K-means minimizes within-cluster variance.
solution / explanation :-
Objective: minimize Σ||x − centroid||²
Question 8
question :-
Two objects are described by 4 categorical variables. They match in 3 variables and differ in 1 variable.
What is the dissimilarity?
options :-
a) 0.25
b) 0.5
c) 0.75
d) 1.0
answer :-
a) 0.25
theory :-
Dissimilarity = mismatches / total variables
solution / explanation :-
1 / 4 = 0.25
Question 9
question :-
Given log-transformed values: Object 1 = 2.65, Object 2 = 1.34, Maximum = 3.08, Minimum = 1.34.
Find normalized dissimilarity:
options :-
a) 0.5
b) 0.75
c) 1.0
d) 0.25
answer :-
b) 0.75
theory :-
Normalized distance:
|x₁ − x₂| / (max − min)
solution / explanation :-
|2.65 − 1.34| = 1.31
Range = 3.08 − 1.34 = 1.74
Dissimilarity = 1.31 / 1.74 ≈ 0.75
Question 10
question :-
Consider two centroids: C₁ = (1,1), C₂ = (5,5). A point P = (2,3). Which cluster will P belong to (using
Euclidean distance)?
options :-
a) Cluster 1
b) Cluster 2
c) Both equally
d) Cannot determine
answer :-
a) Cluster 1
theory :-
Assign to nearest centroid using Euclidean distance.
solution / explanation :-
Distance to C₁ = √[(2−1)² + (3−1)²] = √5
Distance to C₂ = √[(2−5)² + (3−5)²] = √13
√5 < √13 → closer to Cluster 1
WEEK 12
Question 1
question :-
In decision tree algorithm, attribute selection method is used to:
options :-
a) Clean data
b) Choose best splitting attribute
c) Remove outliers
d) Normalize features
answer :-
b) Choose best splitting attribute
theory :-
Attribute selection measures (Information Gain, Gini, Gain Ratio) help select the best feature for
splitting.
solution / explanation :-
Decision trees split data based on feature that gives best separation.
Question 2
question :-
CART follows which approach while building trees?
options :-
a) Top-down greedy
b) Bottom-up greedy
c) Random search
d) Backtracking
answer :-
a) Top-down greedy
theory :-
CART builds tree recursively by choosing best split at each step.
solution / explanation :-
Starts from root → splits downward → greedy decisions at each node.
Question 3
question :-
The Gini index is mainly used for:
options :-
a) Clustering
b) Classification
c) Regression only
d) Sampling
answer :-
b) Classification
theory :-
Gini index measures impurity in classification tasks.
solution / explanation :-
Lower Gini → purer node → better split.
Question 4
question :-
Information gain is biased towards:
options :-
a) Attributes with many values
b) Attributes with fewer values
c) Continuous attributes only
d) Binary attributes only
answer :-
a) Attributes with many values
theory :-
Information Gain favors attributes with many distinct values.
solution / explanation :-
Leads to overfitting → corrected using Gain Ratio.
Question 5
question :-
Gain ratio is used to:
options :-
a) Increase bias
b) Normalize dataset
c) Reduce dataset size
d) Remove bias of information gain
answer :-
d) Remove bias of information gain
theory :-
Gain Ratio adjusts Information Gain by intrinsic information.
solution / explanation :-
Penalizes attributes with many values.
Question 6
question :-
Which of the following ensures binary splits in decision trees?
options :-
a) Information gain
b) Gain ratio
c) Gini index
d) Entropy
answer :-
c) Gini index
theory :-
CART algorithm (uses Gini) produces binary splits.
solution / explanation :-
Each node splits into exactly two branches.
Question 7
question :-
In hierarchical clustering, HAC stands for:
options :-
a) Hierarchical Analytical Clustering
b) Hierarchical Agglomerative Clustering
c) Hybrid Agglomerative Clustering
d) High Accuracy Clustering
answer :-
b) Hierarchical Agglomerative Clustering
theory :-
HAC builds clusters by merging smaller clusters.
solution / explanation :-
Bottom-up clustering approach.
Question 8
question :-
The Euclidean distance formula is used to:
options :-
a) Measure similarity
b) Normalize data
c) Measure dissimilarity
d) Reduce dimensions
answer :-
c) Measure dissimilarity
theory :-
Distance metrics quantify how different two points are.
solution / explanation :-
Higher distance → more dissimilar.
Question 9
question :-
LabelEncoder in Python is used for:
options :-
a) Scaling data
b) Encoding categorical variables
c) Feature selection
d) Data splitting
answer :-
b) Encoding categorical variables
theory :-
LabelEncoder converts categories into numeric labels.
solution / explanation :-
Example: Male → 0, Female → 1.
Question 10
question :-
The function fit_transform() in encoding:
options :-
a) Only fits model
b) Only transforms data
c) Fits and transforms data
d) Deletes missing values
answer :-
c) Fits and transforms data
theory :-
fit() learns parameters, transform() applies them.
solution / explanation :-
fit_transform() combines both steps in one call.