// resources
Resources
All
|
Cheatsheet
Code Example
Exercise
Template
Other
Achievement
|
Basics
Control Flow
Functions
Data Structures
Modules & Packages
Projects
Object-oriented programming
|
↑ oldest first
↓ newest first
// Exercise
bmi_calculator_2.py
BMI Calculator rewritten with parameters — no input() inside. Pass weight and height, function calculates and prints. C…
// Code Example
return_statement.py
return — send a value back to the caller. Store it, print it, pass it on. First return reached stops the function. No r…
// Exercise
username_generator_3.py
Username Generator with return — the value is free. Store it, print it directly, pass it to another function. Three way…
// Exercise
bmi_calculator_3.py
BMI Calculator with return — three functions, three jobs. Calculate, categorize, print. return connects them, each can …
// Code Example
scope.py
Local vs global — where variables live. Local dies with the function, global is readable everywhere. Use return to get …
// Code Example
multiple_return_values.py
Multiple return values — return a, b packs two values, x, y = function() unpacks them. Order matters. Use only what you…
// Code Example
try_except.py
try / except — handle errors gracefully. Wrap code that might fail, catch specific errors, program continues. No crash.
// Code Example
try_except_else_finally.py
try / except / else / finally — the full picture. else runs on success, finally always runs. Use only what you need.
// Code Example
raise_statement.py
raise — throw your own errors. Enforce your function's rules. as e gives access to the message. Always pair with try / …
// Exercise
bmi_calculator_4.py
BMI Calculator with error handling — get_input() validates, calculate_bmi() calculates, get_category() labels. Three fu…
// Other
functions_mistakes.py
6 mistakes almost every beginner makes with functions. Define before calling, parentheses, print vs return, code after …
// Cheatsheet
Functions — The Full Picture
Functions — The Full Picture. def, parameters, return, scope, multiple return values, try/except/else/finally, raise, c…
// Achievement
functions_complete_medal.stl
You finished the Functions chapter. Download, print, and keep it. You earned it.
// Code Example
list_creation.py
List creation — literals, empty lists, range sequences, and string conversion. Every way Python lets you build one.
// Code Example
split_method.py
split() — cutting strings into lists. Default whitespace split, custom separators, maxsplit, and the difference between…