☀
Account Enter the Lab
Courses  /  Programming & Computer Science  /  Programming with Functions
Programming & Computer Science
Programming with Functions

Programming with Functions

Write functions that change pictures one pixel at a time: return a value for every input, find and fix bugs, build functions out of other functions, chain them, and give them more than one input.
6 levels 30 lessons All ages Taught by Church 0 of 30 complete
THE SYLLABUS
I
Introduction to Functions

0 / 7
▶
Filtering Images
A picture is a grid of pixels, each a number from 0 (black) to 255 (white). A program can visit every pixel and decide what it becomes, so one if and one else turn any picture into black and white.
Start
🔒
Adjusting Images
A picture is only numbers, so code can adjust it gently: add 40 to every pixel to lighten it, subtract 40 to darken it, or move only the darkest and lightest pixels to fade or bolden it.
Premium
🔒
Functions
A function is a named piece of code that does one task: black_white takes a value and returns 0 or 255. Two filters that share that task can both call the one function instead of repeating its lines.
Premium
🔒
Returning Values
A function hands a value back with return, and it must return something for every input: clean returns 255 for a light gray input and the input itself for everything else, so every pixel's fate is written down.
Premium
🔒
Debugging Functions
A function that skips a return for some inputs, or returns nothing at all, stops the program. Debugging means finding the inputs with no answer and giving every path its return.
Premium
🔒
Multiple Functions
A program can call several functions, one after another, to layer effects: brighten and then black_white, or soft_clip and then black_gray_white. Each function does one task and hides its details.
Premium
🔒
Level Review
Twelve questions with no hints on the whole level: filters with if and else, functions that return a value for every input, finding and fixing missing returns, and tracing a value through one or two calls.
Premium
II
Coding with Tuples

🔒 6 lessons
III
Debugging Functions

🔒 4 lessons
IV
Function Dependency

🔒 5 lessons
V
Function Composition

🔒 4 lessons
VI
Multiple Inputs

🔒 4 lessons