Lambda
Source: 4-Functions/4.3-Lambda.ipynb
Start here — no coding background needed
What you will learn
One-line mini-functions for quick jobs.
In simple words
Lambda is shorthand when the logic fits in one expression — optional until comfortable with `def`.
Think of it like this
Sticky note function instead of a full recipe card.
Write a recipe once, use it many times — functions save repetition.
Easy example — run this first. Change values and press Run again.
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Reference notes (from full bootcamp)
Optional — deeper detail for when you are ready
Lambda Functions in Python
Lambda functions are small anonymous functions defined using the lambda keyword. They can have any number of arguments but only one expression. They are commonly used for short operations or as arguments to higher-order functions.
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): 5
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): 11
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): True
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): True
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): 39
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): 39
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): 4
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Expected (from notebook): [1, 4, 9, 16, 25, 36]
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Practice test — try yourself
Write code, press Check. Wrong answer shows the correct code to copy & run.
Use lambda to double 7 and print the result (should print 14).