๐Ÿœ๏ธ Year 6 ยท Debugging Dunes
Secret Galactic
Code Academy
Student Workbook
๐Ÿœ๏ธ Debugging Dunes โ€” Debugging & Testing

Year Group: Year 6 ยท Ages 10โ€“11

Theme: Error Types ยท Debug Process ยท try/except ยท Testing

Missions: 10 Workbook Missions ยท 16 Game Missions

Language: Python 3

ยฉ 2026 InfiniCoreCipher โ€” FutureTechEducation | Canon Authority: Katarzyna Kalina vel Kalinowska | v3.0 MASTER CANON LOCKED
๐Ÿ”

Zone 1: Error Canyon

The Three Error Types ยท The Debug Process

Mission 1: Welcome to Debugging Dunes EXPLORE
Year 6Chapter 1โฑ 20 min โญ 80 XP
๐Ÿš€
Nova says:

Welcome to Debugging Dunes, Admiral! Here every bug is a lesson and every fix makes you stronger! Debugging is a SUPERPOWER!

๐Ÿ“ Activity 1.1 โ€” What is Debugging?

In your own words, explain what debugging means:

Name 3 famous bugs in computing history (research if needed):

1.

2.

3.

๐Ÿ“ Activity 1.2 โ€” My Debugging Goals

By the end of Debugging Dunes, I want to be able to:

1.

2.

3.

Mission 2: The Three Error Types CONCEPT
Year 6Chapter 1โฑ 25 min โญ 110 XP
๐Ÿš€
Nova says:

Three types of errors: Syntax โ€” Python won't run it. Logic โ€” wrong answer. Runtime โ€” crashes! Know them all โ€” fix them all!

๐Ÿ”ด Syntax Error

Python won't run the code at all. Like a grammar mistake in English.

Examples: missing colon, = instead of ==, unclosed quote

๐ŸŸ  Logic Error

Code runs but gives wrong answer. Hardest to find!

Examples: wrong operator, wrong condition, case sensitivity

๐ŸŸฃ Runtime Error

Code crashes during execution. Python gives an error message.

Examples: division by zero, index out of range, NameError

๐Ÿ“ Activity 2.1 โ€” Classify the Errors

Write S (Syntax), L (Logic), or R (Runtime) for each:

CodeType (S/L/R)Why?
if score > 80 (missing colon)
score = "100" then score + 50
print(undefined_variable)
if score = 80:
list[10] when list has 5 items
while True: print("hello")
10 / 0
"Nova" == "nova" returns False (wrong)
๐Ÿ“ Activity 2.2 โ€” Read the Error Messages

What does each error message tell you? Write the fix:

SyntaxError: expected ':' after 'if' statement

Problem:

Fix:

NameError: name 'scroe' is not defined

Problem:

Fix:

IndexError: list index out of range

Problem:

Fix:

Mission 3: The Debug Process CONCEPT
Year 6Chapter 1โฑ 25 min โญ 120 XP
๐Ÿš€
Nova says:

The 5-step debug process: READ โ†’ LOCATE โ†’ UNDERSTAND โ†’ FIX โ†’ TEST. Follow it every time โ€” it works!

Step 1: READ โ€” Read the error message carefully. What type? What line?
Step 2: LOCATE โ€” Find the exact line in the code where the error occurs.
Step 3: UNDERSTAND โ€” Why is this an error? What should happen vs what does happen?
Step 4: FIX โ€” Make ONE change to fix the error. Don't change multiple things at once!
Step 5: TEST โ€” Run the code again. Does it work? Are there more errors?
๐Ÿ“ Activity 3.1 โ€” Apply the Debug Process
# BUGGY CODE def calculate_average(numbers): total = 0 for num in numbers: total = total + num return total # BUG HERE scores = [85, 92, 78, 95, 88] avg = calculate_average(scores) print("Average:", avg)
StepYour Answer
1. READ โ€” What is the output?
2. LOCATE โ€” Which line has the bug?
3. UNDERSTAND โ€” Why is it wrong?
4. FIX โ€” Write the corrected line:
5. TEST โ€” What should the output be?
๐Ÿ›

Zone 2: Bug Valley

Syntax Error Hunt ยท Logic Error Detective

Mission 4: Syntax Error Hunt DEBUG
Year 6Chapter 2โฑ 25 min โญ 140 XP
๐Ÿš€
Nova says:

Syntax errors are the easiest to find โ€” Python tells you exactly where they are! Look for: missing colons, wrong operators, unclosed quotes, missing brackets!

๐Ÿ“ Activity 4.1 โ€” Find and Fix the Syntax Errors

Each program has 3 syntax errors. Circle them and write the fixes:

# Program 1 โ€” 3 syntax errors def greet(name) print("Hello" name) print("Welcome to SGCA!) greet("Nova")

Bug 1:

Bug 2:

Bug 3:

Fixed program:

๐Ÿ“ Activity 4.2 โ€” Syntax Error Checklist

Check each item when hunting syntax errors:

CheckWhat to look forExample fix
ColonsAfter if, for, def, else, elif, whileif x > 0:
Operators= vs == (assignment vs comparison)if x == 5:
QuotesOpening and closing quotes match"hello"
BracketsEvery ( has a matching )print(x)
IndentationConsistent spaces (4 spaces)4 spaces per level
Mission 5: Logic Error Detective DEBUG
Year 6Chapter 2โฑ 25 min โญ 150 XP
๐Ÿš€
Nova says:

Logic errors are the sneakiest bugs! The code runs but gives wrong answers. Trace through the code step by step โ€” be a detective!

๐Ÿ“ Activity 5.1 โ€” Find the Logic Errors

Each function has a logic error. Find it and write the fix:

# Bug 1: Grade checker def get_grade(score): if score >= 90: return "A" elif score >= 80: return "B" elif score >= 70: return "C" else: return "A" # BUG!

Bug:

Fix:

# Bug 2: Average calculator def calculate_average(numbers): total = 0 for num in numbers: total += num average = total # BUG! return average

Bug:

Fix:

# Bug 3: Is adult checker def is_adult(age): if found = True: # BUG! return True return False

Bug:

Fix:

๐Ÿ“ Activity 5.2 โ€” Logic Error Types
Logic Error TypeExampleHow to spot it
Wrong operatorif x < 0 instead of if x > 0
Wrong valuereturn "A" in else branch
Case sensitivity"Nova" == "nova" is False
Off-by-onerange(1, 10) misses 10
Wrong formulatotal instead of total/len
๐Ÿงช

Zone 3: Test Lab

try/except ยท Writing Tests ยท Edge Cases

Mission 6: Runtime Error Handler CODING
Year 6Chapter 3โฑ 25 min โญ 150 XP
๐Ÿš€
Nova says:

try/except catches runtime errors before they crash your program! Always print a helpful message in the except block!

๐Ÿ“ Activity 6.1 โ€” try/except Structure
try: result = 100 / 0 print(result) except ZeroDivisionError: print("Cannot divide by zero!")

What does this print?

Without try/except, what would happen?

๐Ÿ“ Activity 6.2 โ€” Add try/except

Add try/except to handle the runtime error in each program:

# Program 1: Division by zero total = 150 count = int(input("How many students? ")) average = total / count print("Average:", average)

Add try/except:

# Program 2: List index out of range scores = [85, 92, 78] index = int(input("Which score? (0-2): ")) print("Score:", scores[index])

Add try/except:

๐Ÿ“ Activity 6.3 โ€” Common Runtime Errors
Error TypeCauseexcept clause
ZeroDivisionErrorDividing by zeroexcept ZeroDivisionError:
ValueErrorWrong type (e.g., int("abc"))
IndexErrorList index out of range
NameErrorVariable not defined
TypeErrorWrong type operation
Mission 7: Writing Tests LOGIC
Year 6Chapter 3โฑ 25 min โญ 140 XP
๐Ÿš€
Nova says:

Tests prove your code works! Write them for every function you create. A good test has: input, expected output, and actual output!

๐Ÿ“ Activity 7.1 โ€” Write Test Cases
def is_even(number): return number % 2 == 0

Write 5 test cases for is_even():

InputExpected ResultTest Code
4Trueprint(is_even(4) == True)
7
0
-2
1
๐Ÿ“ Activity 7.2 โ€” Grade Calculator Tests
def get_grade(score): if score >= 90: return "A" elif score >= 80: return "B" elif score >= 70: return "C" elif score >= 60: return "D" else: return "F"

Write test cases for each grade boundary:

ScoreExpected GradeTest Code
95Aprint(get_grade(95) == "A")
85
75
65
55
90
Mission 8: Edge Cases and Boundary Testing LOGIC
Year 6Chapter 3โฑ 25 min โญ 140 XP
๐Ÿš€
Nova says:

Edge cases are where bugs hide! Test the unusual inputs โ€” empty list, zero, negative numbers, very large numbers. Test the EXACT boundary values!

๐Ÿ“ Activity 8.1 โ€” Identify Edge Cases

For each function, list 3 edge cases to test:

FunctionEdge Case 1Edge Case 2Edge Case 3
calculate_average(numbers)
find_max(numbers)
is_palindrome(word)
๐Ÿ“ Activity 8.2 โ€” Boundary Testing

For get_grade(score) where A = 90+, test the boundaries:

# Test boundary values print(get_grade( )) # Should be A (exactly at A boundary) print(get_grade( )) # Should be B (just below A boundary) print(get_grade( )) # Should be B (exactly at B boundary) print(get_grade( )) # Should be C (just below B boundary) print(get_grade( )) # Should be F (minimum possible) print(get_grade( )) # Should be A (maximum possible)
โญ Star Challenge โ€” Complete Test Suite

Write a complete test suite for calculate_average() including normal cases, edge cases, and boundary values:

๐Ÿ”ง

Zone 4: Debug Workshop

Complete Debug Sessions ยท Master Program

Mission 9: Complete Debug Session CODING
Year 6Chapter 4โฑ 30 min โญ 160 XP
๐Ÿš€
Nova says:

A complete debug session: find ALL bugs, fix them one at a time, write tests to verify. This is professional-level debugging!

๐Ÿ“ Activity 9.1 โ€” Debug the Stats Calculator

This program has 5 bugs (mix of syntax, logic, and runtime). Find and fix them all:

# BUGGY CODE โ€” find all 5 bugs def calculate_stats(scores) if len(scores) = 0: return None total = 0 for score in scores: total = total + score average = total highest = scores[0] for score in scores: if score > highest: highest = score lowest = scores[0] for score in scores: if score < lowest: lowest = score return average, highest, lowest

Bug 1 (line __):

Bug 2 (line __):

Bug 3 (line __):

Bug 4 (line __):

Bug 5 (line __):

๐Ÿ“ Activity 9.2 โ€” Write Tests for Fixed Code

Write test cases to verify your fixed calculate_stats():

InputExpected avgExpected highExpected low
[100]
[0, 100]
[50, 50, 50]
[85, 92, 78, 95, 88]
๐Ÿ†

Final Quest: Debug the Dunes!

Use ALL your debugging skills to fix the systems!

Mission 10: FINAL QUEST โ€” Debug the Dunes! FINAL
Year 6Chapter 5โฑ 60 min โญ 500 XP
๐Ÿš€
Nova says:

DEBUGGING DUNES needs you! Use ALL your debugging skills โ€” syntax, logic, runtime, testing โ€” to fix the systems and save the Dunes!

๐Ÿ† Part 1: Fix 5 Syntax Errors
# BUGGY CODE โ€” 5 syntax errors def check_score(score) if score >= 80: return "Pass" else return "Fail for i in range(10) print(i)

Bug 1:

Bug 2:

Bug 3:

Bug 4:

Bug 5:

๐Ÿ† Part 2: Fix 5 Logic Errors

Each function has a logic error. Write the fix:

def is_adult(age): return age < 18 # Bug 1 def factorial(n): result = 0 # Bug 2 for i in range(1, n+1): result *= i return result def list_length(my_list): return len(my_list) + 1 # Bug 3 def find_max(nums): max_val = nums[0] for num in nums: if num < max_val: max_val = num # Bug 4 return max_val def double_list(nums): result = [] for num in nums: result.append(num) # Bug 5 return result

Fix 1:

Fix 2:

Fix 3:

Fix 4:

Fix 5:

๐Ÿ† Part 3: Handle 3 Runtime Errors

Add try/except to each function:

def safe_divide(a, b): return a / b # Add ZeroDivisionError handler def safe_get(my_list, index): return my_list[index] # Add IndexError handler def safe_int(value): return int(value) # Add ValueError handler
๐Ÿ† Part 4: Write a Complete Test Suite

Write tests for calculate_stats([85, 92, 78, 95, 88]):

๐Ÿ† Part 5: Debug the Master Program

This program has 4 bugs. Find and fix them all:

def station_diagnostic(zones) results = [] for zone in zones: if zone["status"] = "active": power = zone["power"] if power < 50 results.append(f"Zone {zone['id']}: LOW POWER ({power}%)") else: results.append(f"Zone {zone['id']}: OK ({power}%)") return results

Bug 1:

Bug 2:

Bug 3:

Bug 4:

๐Ÿ†
DEBUGGING DUNES CONQUERED!

You've mastered error types, the debug process, try/except, and testing!

Creativity Cluster awaits, Admiral! ๐ŸŽจ

๐Ÿ… Year 6 Master
๐Ÿœ๏ธ Debugging Dunes Champion
๐Ÿ› Bug Hunter Elite

assert

A statement that checks if a condition is True; raises AssertionError if False.

Bug

An error in a program that causes it to behave incorrectly.

Debugging

The process of finding and fixing errors in code.

Edge case

An unusual or extreme input that might cause unexpected behaviour.

except

Catches a specific error type in a try/except block.

Logic error

Code runs but produces wrong results. Hardest to find.

Runtime error

Code crashes during execution (e.g., ZeroDivisionError, IndexError).

Syntax error

Code violates Python's grammar rules; Python won't run it.

Test case

A specific input with an expected output used to verify code works.

Trace

Following code step by step to understand what it does.

try

Attempts code that might raise an error.

ZeroDivisionError

Runtime error when dividing by zero.