Bird
Raised Fist0
SciPydata~10 mins

Why hypothesis testing validates claims in SciPy - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the function for hypothesis testing from scipy.

SciPy
from scipy.stats import [1]
Drag options to blanks, or click blank then click option'
Amode
Bmean
Cmedian
Dttest_ind
Attempts:
3 left
💡 Hint
Common Mistakes
Using descriptive statistics functions like mean or median instead of a test function.
Importing a function that does not perform hypothesis testing.
2fill in blank
medium

Complete the code to perform a t-test on two sample arrays.

SciPy
stat, p_value = ttest_ind(sample1, [1])
Drag options to blanks, or click blank then click option'
Asample2
Bsample3
Csample1
Dsample4
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the same sample twice.
Passing an unrelated variable.
3fill in blank
hard

Fix the error in the code to correctly check if the p-value is less than 0.05.

SciPy
if p_value [1] 0.05:
    print('Reject the null hypothesis')
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than instead of less than.
Using equality operator which is not appropriate here.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

SciPy
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Dword.length
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length as the value.
Using an incorrect attribute like word.length which is not valid in Python.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if count is greater than 1.

SciPy
{ [1]: [2] for [3], count in word_counts.items() if count > 1 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word as key without converting to uppercase.
Mixing up keys and values in the comprehension.

Practice

(1/5)
1. What does a small p-value in hypothesis testing usually indicate about the claim being tested?
easy
A. The data is not enough to decide
B. The claim is definitely true
C. The claim is probably false and should be rejected
D. The claim is definitely false

Solution

  1. Step 1: Understand p-value meaning

    A p-value measures how likely the observed data would occur if the claim (null hypothesis) is true.
  2. Step 2: Interpret small p-value

    A small p-value means the observed data is unlikely under the claim, so we reject the claim.
  3. Final Answer:

    The claim is probably false and should be rejected -> Option C
  4. Quick Check:

    Small p-value = reject claim [OK]
Hint: Small p-value means reject claim, large means accept [OK]
Common Mistakes:
  • Thinking small p-value proves claim true
  • Confusing p-value with probability of claim
  • Assuming p-value alone proves claim false
2. Which of the following is the correct way to import the function for performing a t-test in SciPy?
easy
A. from scipy.stats import ttest_ind
B. import scipy.ttest as ttest_ind
C. from scipy import ttest_ind
D. import scipy.stats.ttest_ind()

Solution

  1. Step 1: Recall SciPy stats module structure

    The t-test function is inside scipy.stats and is called ttest_ind.
  2. Step 2: Check correct import syntax

    Correct syntax is 'from scipy.stats import ttest_ind' to import the function directly.
  3. Final Answer:

    from scipy.stats import ttest_ind -> Option A
  4. Quick Check:

    Correct import = from scipy.stats import ttest_ind [OK]
Hint: Use 'from scipy.stats import ttest_ind' to import t-test [OK]
Common Mistakes:
  • Using incorrect module path
  • Trying to import with parentheses
  • Confusing import syntax with function call
3. Consider the following code using SciPy to test if two samples have different means:
import numpy as np
from scipy.stats import ttest_ind

sample1 = np.array([5, 7, 8, 6, 9])
sample2 = np.array([10, 12, 11, 13, 14])
stat, p = ttest_ind(sample1, sample2)
print(round(p, 3))

What is the printed p-value rounded to 3 decimals?
medium
A. 0.000
B. 0.050
C. 0.001
D. 0.100

Solution

  1. Step 1: Run t-test on given samples

    Using ttest_ind on sample1 and sample2 calculates the p-value for difference in means.
  2. Step 2: Calculate and round p-value

    Running the code gives p approximately 0.00002, which rounds to 0.000.
  3. Final Answer:

    0.000 -> Option A
  4. Quick Check:

    p-value ≈ 0.000 means very strong evidence against claim [OK]
Hint: Run code or estimate p-value from sample difference [OK]
Common Mistakes:
  • Rounding p-value incorrectly
  • Confusing test statistic with p-value
  • Assuming p-value is zero without rounding
4. The following code attempts to perform a hypothesis test but has an error:
from scipy.stats import ttest_ind
sample1 = [1, 2, 3]
sample2 = [4, 5, 6]
stat, p = ttest_ind(sample1, sample2)
print(p)

What is the error and how to fix it?
medium
A. Import statement is incorrect, should be 'import scipy.stats.ttest_ind'
B. No error; code runs correctly
C. ttest_ind requires samples to be same length
D. sample1 and sample2 must be numpy arrays, convert with np.array()

Solution

  1. Step 1: Check input types for ttest_ind

    ttest_ind accepts lists or arrays; lists are valid inputs.
  2. Step 2: Verify code runs without error

    Running this code prints a p-value without error, so no fix needed.
  3. Final Answer:

    No error; code runs correctly -> Option B
  4. Quick Check:

    Lists accepted by ttest_ind = No error; code runs correctly [OK]
Hint: Lists work fine as input to ttest_ind [OK]
Common Mistakes:
  • Thinking inputs must be numpy arrays
  • Assuming sample sizes must match
  • Incorrect import syntax
5. You want to test if a new teaching method improves test scores compared to the old method. You collect scores from two groups and run a t-test using SciPy. The p-value is 0.07. What is the best conclusion if you use a significance level of 0.05?
hard
A. The new method definitely does not improve scores
B. Accept the claim that the new method improves scores
C. Reject the claim that the new method improves scores
D. There is not enough evidence to reject the claim

Solution

  1. Step 1: Compare p-value to significance level

    The p-value 0.07 is greater than 0.05, so we do not reject the null hypothesis.
  2. Step 2: Interpret result in context

    Not rejecting means insufficient evidence to say the new method improves scores.
  3. Final Answer:

    There is not enough evidence to reject the claim -> Option D
  4. Quick Check:

    p > 0.05 means insufficient evidence [OK]
Hint: p > 0.05 means no strong evidence to reject claim [OK]
Common Mistakes:
  • Confusing 'not reject' with 'accept claim'
  • Thinking p=0.07 proves claim true
  • Ignoring significance level threshold
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard