Code Legions0.133 (beta)
HomeCode KingdomExercises
Sign in
Code KingdomQuestsGame modesCreateGalleryGuide

3Functions and errors

Breaking a job into named pieces, and handling things going wrong: functions, errors, tests, scope and recursion.

0 of 41 quests 0

You're playing as a guest: your progress won't be saved until you sign in.

Sign in Make an account

1 Functions

Name your own commands with def: parameters, return values, and a toolbox of your own.

2 Errors

When things go wrong: reading error messages, try and except, finally, raise, and your own exceptions.

3 Testing

Hunting bugs down: print clues, assert, edge cases, tests that catch them, and a full inspection.

4 Scope and arguments

Where names live: local names, global, defaults, keyword arguments, *args and **kwargs.

5 Recursion

Functions that call themselves: base cases, flood fill and a labyrinth.

6 Functions as values

Passing rules around: key functions, lambda, closures, map and filter.