Practice Exam 1 (Sessions 1-14)

Updated

October 15, 2026

Practice Exam based on Sessions 1–14

Format: Written, closed-book Time limit: 2 h. Total: 100 points.

Important: Where a question asks you to “justify,” credit is given for the reasoning, not just the final answer.


Section A: Coding (46 points)

  • Assume the following imports are already in place unless a question states otherwise:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import statistics as pystats
from scipy import stats as spstats
import pingouin as pg

Code comprehension — short (12 points)

Read each snippet and answer. Assume code runs exactly as written.

A1. (3 pts) What is printed?

masses = [18.02, 44.01, 28.01, 16.04]
print(masses[1], masses[-1], len(masses))

A2. (2 pts) What is the value and type of result?

yields = [78, 81, 74, 90]
result = sum(yields) / len(yields)
print(result, type(result))

A3. (2 pts) What does this print, and why does it not print 4?

readings = [2.1, 3.4, 2.9, 3.1]
count = 0
for r in readings:
    if r > 3:
        count += 1
print(count)

A4. (2 pts) What is the final value of d?

d = {"HCl": 79.3, "AcOH": 88.2}
d["HCl"] = 80.0
d["HCOOH"] = 65.5
print(d)

A5. (3 pts) What is printed? Explain the role of try/except here.

raw = ["4.2", "n/a", "3.9"]
clean = []
for x in raw:
    try:
        clean.append(float(x))
    except ValueError:
        clean.append(np.nan)
print(clean)

Code comprehension — extended (18 points)

Trace each snippet carefully. Assume code runs exactly as written.

A6. (6 pts) Below, samples is a list of dictionaries.

samples = [
    {"id": "A1", "yield": 82, "pure": True},
    {"id": "A2", "yield": 45, "pure": False},
    {"id": "A3", "yield": 91, "pure": True},
    {"id": "A4", "yield": 67, "pure": True},
]
keep = []
total = 0
for s in samples:
    if s["pure"] and s["yield"] > 70:
        keep.append(s["id"])
        total += s["yield"]
print(keep)
print(total / len(keep))
  1. (3 pts) What are the two lines that are printed?
  2. (3 pts) The second printed line is an average. Explain, in one sentence, over which samples the average is computed and why A4 is not among them.

A7. (6 pts) The following builds on a pandas DataFrame.

df = pd.DataFrame({"c1": [10, 20], "c2": [30, 40], "c3": [50, 60]})
targets = ["c1", "c3"]
for col in df:
    if col in targets:
        df[f"{col}_n"] = df[col] / 10
print(df.columns.tolist())
  1. (3 pts) What is printed?
  2. (3 pts) When you write for col in df:, what does the loop variable col take as its values on each iteration? Why is no new column created for c2?

A8. (6 pts) The loop below processes raw instrument readings.

raw = ["3.1", "", "4.5", "x", "2.8"]
vals, bad = [], 0
for r in raw:
    try:
        vals.append(float(r))
    except ValueError:
        bad += 1
print(len(vals), bad, round(sum(vals) / len(vals), 2))
  1. (4 pts) What is printed?
  2. (2 pts) Which entries of raw cause the except block to run, and what would happen to the program if the try/except were removed?

Short code writing — single lines (16 points)

Write a single line of Python for each. Assume the imports above.

A9. (2 pts) Create a list named temps containing the values 20, 25, 30, 35, 40.

A10. (3 pts) Using range, create a list named concs of the values 0, 100, 200, …, 1000.

A11. (2 pts) Create a dictionary named expt with keys "catalyst" (value "Pd") and "yield" (value 88.2).

A12. (3 pts) Given a list data, write one line that creates a new list highs containing only the entries of data greater than 50 (use a list comprehension).

A13. (3 pts) Given a DataFrame df with a column "yield", write one line that adds a new column "yield_frac" equal to the "yield" column divided by 100.

A14. (3 pts) Given two lists c1 and c2, write one line that runs an unpaired two-sided independent t-test with pingouin and stores it in res.


Section B: Statistics & Data Analysis (54 points)

Short-form answers (24 points)

Answer in 1–4 sentences each.

B1. (3 pts) State the null hypothesis (H₀) and the alternative hypothesis (H₁) for the research question: “Does catalyst A give a higher yield than catalyst B?”

B2. (3 pts) For each case below, state whether the outcome is a Type I or a Type II error. a) A QC lab tests whether a reagent batch deviates from spec. The batch is actually within spec, but the test flags it as off-spec and the batch is discarded. b) A new catalyst genuinely outperforms the old one, but the experiment returns p = 0.21 and the team concludes there is no improvement. c) A screen reports a compound as a “hit” (active), when the compound is in fact inactive.

B3. (4 pts) A colleague says: “The p-value is the probability that the null hypothesis is true.” Explain why this is wrong, and give a correct one-sentence definition of a p-value.

B4. (3 pts) Two catalysts give yields of 220 ± 30 and 340 ± 60 (n = 5). What is the fold-change, and name one thing fold-change does not account for that effect size accounts for.

B5. (3 pts) A study compares two catalysts with n = 6 per group, and a reviewer asks for an effect size. State which of Cohen’s d or Hedges’ g is more appropriate here, and explain why in one sentence.

B6. (3 pts) A colleague has designed an experiment but finds it is underpowered. The effect size is fixed by the chemistry, and they need to keep α = 0.05. Name an experimental factor they can change to obtain higher power in a repeat experiment, how this is related to power, and how should they change that factor to gain power.

B7. (5 pts) Your data are not normally distributed. You want to compare two independent groups. Name the appropriate test, and explain in two sentences how this test differs from an analogous test for normally distributed data and why it has lower power than its parametric equivalent.

Long-form answers (30 points)

B8. Catalyst screen (18 pts)

You are testing whether a new catalyst improves reaction yield over your normal catalyst. You collect:

No catalyst (negative control): [3.1, 4.0, 2.8, 3.5, 4.2]
Normal catalyst (positive control): [30.2, 34.5, 28.7, 33.9, 36.1]
New catalyst:                        [71.2, 68.5, 90.1, 74.0, 69.8]
  1. (3 pts) Identify the role of the “No catalyst” group and the “Normal catalyst” group. Why is each included?

  2. (2 pts) State an appropriate null hypothesis for comparing the new catalyst to your normal catalyst.

  3. (6 pts) Outline, in order, the analysis workflow you would follow to decide whether the difference between the new and normal catalyst is statistically meaningful. (You may list the steps.)

  4. (4 pts) One value in the “New catalyst” group (90.1) looks far from the others. State one legitimate reason you would be allowed to remove it, and one method (name it) for objectively flagging it as an outlier.

  5. (3 pts) Would it be acceptable to remove 90.1 simply because doing so makes your p-value more significant? Explain what this practice is called and why it is a problem.

B9. Reading a result (12 pts)

A paper reports: “The engineered enzyme was significantly faster than wild type (p < 0.001).” The figure shows the two means are very close with large, overlapping error bars, and n = 3 per group.

  1. (4 pts) Give two distinct reasons this “significant” result might not be scientifically important or trustworthy.

  2. (4 pts) Name two additional quantities (beyond the p-value) you would want reported to properly interpret this comparison, and say what each one tells you.

  3. (4 pts) The authors conclude from a separate, non-significant comparison (p = 0.30, n = 3) that “the two linkers have no effect on activity.” Explain why “not significant” does not establish “no effect” here, and name one framework from the course that can provide evidence in favor of no difference.


End of practice exam.