← Back to CRAFT PD Series

AI Error Gallery & Code Snippets

Real examples of AI-generated STEM errors — annotated with what went wrong, why, and what to learn from it. Use for the error hunt breakout activities. Click each card to expand.

Code Error Snippets

Use these for the Workshop 2 "Code Error Hunt" breakout. Each snippet has a subtle bug the AI introduced.

Code Snippet 1: Projectile Range Calculator Physics · Grades 9-12 Reveal

"Write a Python function that calculates the range of a projectile given initial velocity (m/s) and launch angle (degrees). Use the standard range equation."

import math

def projectile_range(velocity, angle):
    """Calculate the range of a projectile.
    velocity: initial velocity in m/s
    angle: launch angle in degrees
    Returns: range in meters
    """
    g = 9.81  # acceleration due to gravity
    range_m = (velocity ** 2 * math.sin(2 * angle)) / g
    return round(range_m, 2)

# Example: 20 m/s at 45 degrees
print(projectile_range(20, 45))  # Expected: ~40.77 m
Missing degree-to-radian conversion. math.sin() expects radians, but the angle is passed in degrees. math.sin(2 * 45) computes sin(90) in radians (≈ 0.894), not sin(90°) which equals 1.0. The output is 36.49 instead of the correct 40.77. It's close enough to look plausible — which makes it dangerous.
    angle_rad = math.radians(angle)
    range_m = (velocity ** 2 * math.sin(2 * angle_rad)) / g
This is the #1 physics coding bug. AI models frequently forget the degree/radian conversion because the equation is "correct" without it — the code runs, it produces a number, and the number is even in the right ballpark. Students need to verify outputs against known values (45° should give maximum range ≈ v²/g).
Code Snippet 2: Average Temperature Calculator Environmental Science · Grades 6-8 Reveal

"Write a Python function that takes a list of daily temperatures and returns the average, minimum, and maximum."

def temp_stats(temperatures):
    """Return average, min, and max temperature."""
    total = 0
    for temp in temperatures:
        total += temp
    average = total / len(temperatures)
    minimum = min(temperatures)
    maximum = max(temperatures)
    return {
        "average": round(average, 1),
        "min": minimum,
        "max": maximum
    }

# Test with a week of data
week = [72, 68, 75, 80, 77, None, 73]
print(temp_stats(week))
No handling of missing data. The test data includes None (a common real-world scenario — a sensor goes offline, a student misses a reading). The function crashes with TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'. The AI wrote clean code for clean data but real data is rarely clean.
def temp_stats(temperatures):
    clean = [t for t in temperatures if t is not None]
    if not clean:
        return {"average": None, "min": None, "max": None}
    average = sum(clean) / len(clean)
    return {"average": round(average, 1), "min": min(clean), "max": max(clean)}
AI assumes perfect data. Real-world sensor data always has gaps, errors, and outliers. This connects beautifully to Workshop 3's micro:bit data collection — students will encounter missing readings and need to handle them.
Code Snippet 3: pH Classification Chemistry · Grades 6-8 Reveal

"Write a function that classifies a pH value as acidic, neutral, or basic."

def classify_ph(ph):
    """Classify pH as acidic, neutral, or basic."""
    if ph < 7:
        return "acidic"
    if ph == 7:
        return "neutral"
    if ph > 7:
        return "basic"

# Test
print(classify_ph(6.8))   # acidic ✓
print(classify_ph(7.0))   # neutral ✓
print(classify_ph(7.2))   # basic ✓
print(classify_ph(-1))    # acidic? 🤔
print(classify_ph(15))    # basic? 🤔
Two errors: (1) No input validation — pH of -1 or 15 is physically meaningless (valid range is 0-14), but the function happily classifies them. (2) Using == 7 for "neutral" is scientifically misleading — water at different temperatures has pH ≠ 7.0, and the "neutral" range in practice is roughly 6.5-7.5.
def classify_ph(ph):
    if ph < 0 or ph > 14:
        return "invalid (pH must be 0-14)"
    if ph < 6.5:
        return "acidic"
    if ph <= 7.5:
        return "approximately neutral"
    return "basic"
AI writes code that's logically correct but scientifically naive. The boundary conditions (what values are valid? what range counts as "neutral"?) require domain knowledge the AI doesn't reliably apply. This is why STEM teachers — not AI — are essential.

Content Errors

AI-generated STEM explanations that sound right but contain subtle inaccuracies.

Content Photosynthesis Explanation Biology · Grade 8 Reveal
"Photosynthesis is the process by which plants convert sunlight, water, and carbon dioxide into glucose and oxygen. This process takes place primarily in the leaves, specifically in the chloroplasts. The chlorophyll in chloroplasts absorbs all wavelengths of visible light to power the reaction. The chemical equation is: 6CO₂ + 6H₂O → C₆H₁₂O₆ + 6O₂. Photosynthesis is the only way plants obtain energy."
Error 1: "absorbs all wavelengths of visible light" — False. Chlorophyll primarily absorbs red and blue light, and reflects green light (that's why plants look green). This is a fundamental concept students need.

Error 2: "only way plants obtain energy" — Misleading. Plants also perform cellular respiration to release energy from glucose. Photosynthesis produces glucose; respiration releases its energy. Some plants can also absorb nutrients through roots in parasitic or mycorrhizal relationships.
Content Gravity Explanation Physics · Grade 6 Reveal
"Gravity is the force that pulls objects toward the center of the Earth. The strength of gravity depends on the mass of the object — heavier objects experience more gravitational pull and therefore fall faster than lighter objects. This is why a bowling ball falls faster than a feather. On Earth, gravity accelerates objects at 9.8 meters per second squared."
"heavier objects fall faster" — This is the classic Aristotelian misconception that Galileo disproved. In a vacuum, all objects fall at the same rate regardless of mass. A bowling ball and a feather fall at different rates in air because of air resistance, not because of different gravitational pull. The AI reinforced exactly the misconception a physics teacher would spend a week correcting.
Content CPU Architecture Explanation Computer Science · Grade 10 Reveal
"A CPU processes instructions in a cycle called fetch-decode-execute. The CPU processes one instruction at a time, sequentially reading from memory. Modern CPUs are fast because they have higher clock speeds, which means they can process more instructions per second. A 3 GHz processor processes 3 billion instructions per second."
Error 1: "processes one instruction at a time" — This hasn't been true since the 1990s. Modern CPUs use pipelining, superscalar execution, and out-of-order execution to process multiple instructions simultaneously. Even a basic explanation should mention that modern CPUs overlap instructions.

Error 2: "3 GHz = 3 billion instructions per second" — Clock cycles ≠ instructions. A single instruction may take multiple cycles, and modern CPUs can also complete multiple instructions per cycle (IPC). 3 GHz means 3 billion clock cycles, not instructions.
Content Evolution of Antibiotic Resistance Biology · Grade 9 Reveal
"When bacteria are exposed to antibiotics, they develop mutations to become resistant. The bacteria that survive pass on their resistance to the next generation. Over time, the entire population becomes resistant. This is why doctors tell you to finish your entire course of antibiotics — so the bacteria don't have time to evolve resistance."
Error 1: "develop mutations to become resistant" — This implies bacteria intentionally mutate in response to antibiotics (Lamarckian thinking). In reality, mutations occur randomly before antibiotic exposure. The antibiotic then selects for already-resistant bacteria. The mutation doesn't happen BECAUSE of the antibiotic.

Error 2: The reason for finishing antibiotics — The explanation is oversimplified. Finishing the course primarily ensures the infection is fully cleared, reducing the population of bacteria that could serve as a reservoir. The relationship between incomplete courses and resistance is actually more nuanced than presented here — recent research has questioned the "always finish" dogma.
Content What Causes Earth's Seasons Earth Science · Grade 6 Reveal
"Earth experiences seasons because of its elliptical orbit around the Sun. When Earth is closer to the Sun, we have summer, and when it is farther away, we have winter. That's why the Northern Hemisphere is warmer in July and colder in January — Earth's distance to the Sun changes throughout the year."
This is the most common seasons misconception — and it's completely wrong. Seasons are caused by Earth's axial tilt (23.5°), not its distance from the Sun. In fact, Earth is closest to the Sun in early January (perihelion), when the Northern Hemisphere is in winter. If distance caused seasons, both hemispheres would have the same season simultaneously — they don't. The Harvard "A Private Universe" study famously showed even Ivy League graduates held this misconception. An AI reinforcing it is a textbook example of why teacher review matters.
Content Newton's Third Law Applied to Motion Physics · Grade 9 Reveal
"Newton's Third Law says that for every action there is an equal and opposite reaction. So when a horse pulls a cart, the cart pulls back on the horse with equal force. Because these forces are equal and opposite, they cancel out — which is why it takes extra effort from the horse to overcome this cancellation and get the cart moving."
Action-reaction pairs never "cancel out." They act on different objects — the horse pushes the cart, the cart pushes the horse. Forces only cancel when they act on the same object. The cart accelerates because the net force on the cart (horse's pull minus friction) is nonzero. This "forces cancel" misconception is so persistent it has its own name in physics education research (the "horse-cart paradox"). AI-generated explanations frequently fall into exactly this trap.
Content Mitochondria and Cell Types Biology · Grade 7 Reveal
"Mitochondria are the powerhouse of the cell. They produce energy for the cell by breaking down glucose. Mitochondria are found in animal cells, while plant cells use chloroplasts instead to make their energy. This is one of the key differences between plant and animal cells."
Error 1: "plant cells use chloroplasts instead" — Plant cells have both mitochondria and chloroplasts. Chloroplasts make glucose (via photosynthesis); mitochondria break it down to release usable ATP. Without mitochondria, plants couldn't access the energy they've stored.

Error 2: "produce energy" — Mitochondria don't produce energy; they transfer chemical energy from glucose to ATP. Energy is conserved, not created. This is a small but foundational distinction for later thermodynamics units.
Content Speed of Light Physics · Grade 11 Reveal
"The speed of light is a universal constant: light always travels at exactly 299,792,458 m/s, no matter what medium it passes through. This is one of the foundational postulates of Einstein's special relativity. That's why c shows up in equations like E=mc²."
Light only travels at c in a vacuum. In glass, light slows to about 2×10⁸ m/s (index of refraction ≈ 1.5); in water it's about 2.25×10⁸ m/s; in diamond, only ~1.24×10⁸ m/s. This slowing is exactly why refraction happens — lenses, prisms, and even the bending of a straw in a glass of water depend on it. The precise statement is that the speed of light in a vacuum is invariant. An AI answer that drops "in a vacuum" turns a correct physics fact into a wrong one.
Content DNA Base Pairing Biology · Grade 10 Reveal
"DNA is made of four bases: adenine (A), thymine (T), guanine (G), and cytosine (C). These bases pair up across the double helix: A pairs with G, and T pairs with C. Hydrogen bonds hold the pairs together — two bonds between A-G and three bonds between T-C. This is called complementary base pairing."
Error 1: The pairings are swapped. A pairs with T (not G), and G pairs with C (not T). This is the single most fundamental fact in molecular biology — and the AI got it backward while sounding completely authoritative.

Error 2: The hydrogen bond counts are assigned to the wrong pairs. A–T has 2 hydrogen bonds; G–C has 3 hydrogen bonds. This is why GC-rich DNA has a higher melting temperature. If a student memorizes the AI's version, every downstream concept — replication, transcription, PCR temperatures — breaks.

Standards Errors

Standards Hallucinated NGSS Code Cross-subject Reveal
"This lesson aligns to NGSS MS-PS3-7: Students who demonstrate understanding can apply scientific principles to design, construct, and test a device that converts thermal energy to electrical energy."
MS-PS3-7 does not exist. The MS-PS3 cluster only goes up to MS-PS3-5. The AI invented a plausible-sounding code and wrote a plausible-sounding description. If you don't check the NGSS website, you'd never know. The actual closest standard is MS-PS3-3 (thermal energy design problem).
Standards Wrong Grade Band Cross-subject Reveal
"For this 4th grade lesson on ecosystems, align to NGSS HS-LS2-1: Use mathematical and/or computational representations to support explanations of factors that affect carrying capacity."
HS-LS2-1 is a high school standard (note the "HS-" prefix), not appropriate for 4th grade. The correct grade band would be elementary (e.g., 5-ESS3-1 for human impact on environments) or middle school. The AI grabbed the right topic but the wrong grade band — a common failure mode.

Math Errors

Math Significant Figures Chemistry · Grade 10 Reveal
"If you have 12.5 mL of a solution with a concentration of 0.102 M, the number of moles is: n = M × V = 0.102 × 0.0125 = 0.001275 moles"
Too many significant figures. 12.5 mL has 3 significant figures and 0.102 M has 3 significant figures. The answer should be reported as 0.00128 moles (3 sig figs), not 0.001275 (4 sig figs). AI almost never applies significant figure rules correctly.
Math Statistics Word Problem Math · Grade 7 Reveal
"A basketball player scores: 12, 15, 18, 22, 15, 20, 15 points in seven games. Find the mean, median, and mode.

Mean: (12+15+18+22+15+20+15)/7 = 117/7 = 16.7
Median: Arrange in order: 12, 15, 15, 15, 18, 20, 22. Middle value = 15
Mode: 15 (appears 3 times) ✓"
Wrong mean. 12+15+18+22+15+20+15 = 117. Then 117/7 = 16.714..., which rounds to 16.7. Wait — that's actually correct! But the AI showed 16.7 without specifying rounding, which could confuse students about precision. More importantly: the sum is actually correct here, but in many AI-generated stats problems the arithmetic is wrong. Always re-sum yourself. The teaching point: even when the AI gets it right, you need to verify. Trust but verify.
Math Order of Operations Math · Grade 6 Reveal
"Evaluate: 8 ÷ 2(2 + 2)

Step 1: Solve the parentheses first: (2 + 2) = 4
Step 2: The expression becomes 8 ÷ 2(4), and since 2(4) means multiplication, solve it next: 2 × 4 = 8
Step 3: Now we have 8 ÷ 8 = 1"
Wrong answer — and wrong reasoning. Under standard PEMDAS/BODMAS, multiplication and division have equal precedence and are evaluated left-to-right. So 8 ÷ 2(4) = 8 ÷ 2 × 4 = 4 × 4 = 16, not 1. The AI treated implicit multiplication as higher precedence — a convention used in some physics texts but not in K-12 math standards. Worse, it stated its reasoning so confidently that students would trust it. The deeper lesson: this expression is genuinely ambiguous in real mathematical writing, which is why professionals use explicit parentheses. AI picked one convention and didn't flag the ambiguity.
Math Unit Conversion: Area vs. Length Math · Grade 7 Reveal
"A rectangular garden is 3 meters by 4 meters. Convert its area to square centimeters.

Area = 3 m × 4 m = 12 m²
Since 1 m = 100 cm, we convert:
12 m² × 100 = 1,200 cm²"
Wrong conversion factor for area. 1 m² = (100 cm)² = 10,000 cm², not 100 cm². The correct answer is 120,000 cm². The AI treated a squared unit like a linear one — a classic mistake students make constantly. What makes this dangerous is the answer (1,200) looks like a reasonable-ish number, so it passes a surface "does this look right?" check. The real gut check: a 3 m × 4 m garden is enormous; 1,200 cm² is smaller than a dinner plate. Teachers should coach students to sanity-check with extreme cases.
Math Percent Change Reversal Math · Grade 8 Reveal
"A shirt's price increased by 20%, then later decreased by 20%. What is the net change?

Since the increase and decrease are both 20%, they cancel out — the final price equals the original price, so the net change is 0%."
Percentages don't work this way. If the original price is $100: after a 20% increase it becomes $120; after a 20% decrease of $120, it becomes $96. The net change is a 4% decrease, not zero. The two percentages apply to different base values, so they don't cancel. This is the single most common percent-change misconception and shows up every year in state-test items. AI models frequently generate this exact wrong reasoning because it pattern-matches to "what feels symmetric."
Math Probability of Dependent Events Math · Grade 7 Reveal
"A bag has 3 red marbles and 2 blue marbles. You draw two marbles without replacement. What is the probability that both are red?

P(red) = 3/5
P(both red) = 3/5 × 3/5 = 9/25"
Treated a dependent event as independent. After drawing one red marble without replacement, only 2 red marbles remain out of 4 total. So:
P(both red) = (3/5) × (2/4) = 6/20 = 3/10
The multiplication rule P(A) × P(B) only works when events are independent. "Without replacement" changes the sample space for the second draw. AI models regularly collapse this distinction — especially on word problems where the key phrase is just two words long.
Math Negative Exponents Math · Grade 8 Reveal
"Simplify: 2⁻³

A negative exponent means you multiply and then make the answer negative. So 2⁻³ = −(2 × 2 × 2) = −8."
Negative exponents don't make numbers negative. A negative exponent means reciprocal: 2⁻³ = 1/2³ = 1/8. The result is positive — in fact, a positive base raised to any integer exponent (positive or negative) is always positive. The AI confused the sign of the exponent with the sign of the result, producing a number (−8) that's wrong in both magnitude and sign. This error pattern — "minus sign floats to wherever it feels natural" — shows up constantly in AI-generated algebra solutions.

CRAFT PD Series · UCF DRACO Lab & School of Teacher Education