// resources

Resources

// Code Example
def_function.py
def — define a function once, call it anywhere. Parentheses required, indentation mandatory, defining doesn't run it — …
20 downloads 04 May 2026 → Your first function
[ download ]
// Exercise
banner.py
Banner — def in action. One function, consistent output, call it as many times as you need. "=" * len(title) fits the b…
26 downloads 04 May 2026 → DEF Mini Project — Banner
[ download ]
// Code Example
parameters.py
Parameters — pass values into a function, function uses them. One function, many possible inputs. Parameter in definiti…
[ download ]
// Code Example
default_parameters.py
Default parameters — a fallback value when you don't pass one. Required parameters first, defaults after. Override when…
19 downloads 05 May 2026 → A value if you don't provide one
[ download ]
// Exercise
username_generator_2.py
Username Generator rewritten with parameters — no input() inside. Pass what changes, keep what stays. Default prefix in…
[ download ]
// Exercise
bmi_calculator_2.py
BMI Calculator rewritten with parameters — no input() inside. Pass weight and height, function calculates and prints. C…
[ download ]
// 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…
19 downloads 05 May 2026 → Your function finally talks back
[ download ]
// 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…
[ download ]
// Exercise
bmi_calculator_3.py
BMI Calculator with return — three functions, three jobs. Calculate, categorize, print. return connects them, each can …
[ download ]
// Code Example
scope.py
Local vs global — where variables live. Local dies with the function, global is readable everywhere. Use return to get …
[ download ]
// 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…
19 downloads 05 May 2026 → Return two things at once
[ download ]
// Code Example
try_except.py
try / except — handle errors gracefully. Wrap code that might fail, catch specific errors, program continues. No crash.
19 downloads 05 May 2026 → Don't let errors crash your program
[ download ]
// 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.
[ download ]
// 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 / …
19 downloads 05 May 2026 → Throw your own errors
[ download ]
// Exercise
bmi_calculator_4.py
BMI Calculator with error handling — get_input() validates, calculate_bmi() calculates, get_category() labels. Three fu…
[ download ]
« first« ← prev 1 / 2 next → last »»