Interactive Computer Science Tutoring

Learn programming concepts interactively

AHA Schools Logo

Error Detection Lab

Master Python error handling through medical metaphors and interactive diagnosis

0
Detection Score
0
Handling Score
basic
Current Level
0
Memory Checks
50%
Self-Confidence
Error Hospital - Patient #1critical
Diagnose the error type and provide the appropriate treatment
Patient Code:
if x = 5:
    print('Hello')

Prediction Challenge: What error will this code cause?

Quick Diagnosis:

Patient 1 of 5
Exception Matching LaboratoryScore: 0
Drag error messages to their corresponding exception types

Error Messages:

"invalid literal for int() with base 10: 'hello'"
"list index out of range"
"division by zero"
"name 'undefined_var' is not defined"

Exception Types:

ValueError
Drop message here
IndexError
Drop message here
ZeroDivisionError
Drop message here
NameError
Drop message here
Matched: 0/4
Error Analysis Code
Live Python error analysis with medical metaphors
# Error Detection Lab - Python Exception Analysis
# Current Patient (Error) Under Analysis:
# Status: CRITICAL - Using assignment (=) instead of comparison (==) in if statement
# Problematic Code:
if x = 5: # ⚠️ This will cause SyntaxError
print('Hello') # ⚠️ This will cause SyntaxError
# Treatment (Try/Except Prescription):
try:
if x = 5:
print('Hello')
except SyntaxError as e:
print(f"Treated SyntaxError: {e}")
# Patient stabilized! ✅
Medical Log0/5
Recent operations with timestamps

No operations yet

Start by adding or modifying elements

Learning Objectives

Basic Level

  • • Identify syntax vs runtime errors
  • • Recognize common exception types
  • • Understand error messages

Intermediate Level

  • • Write try/except blocks
  • • Handle specific exceptions
  • • Use finally for cleanup

Advanced Level

  • • Create custom exceptions
  • • Exception hierarchy understanding
  • • Advanced error handling patterns