Foundation lesson for functions. Understand definition and call mechanics first, then see how functions model real workflows.
def names the machine. You pass inputs (arguments). It returns an output.
Call it many times. You write the body once.
A function is a reusable block of code with a name. You call it whenever you need the same logic again.
Used to organize code in every app: calculation helpers, API utilities, validation checks, and repeated workflows.
def name(params): — use as many times as needed.def greet(name="World")) make arguments optional.An e-commerce site needs to compute tax, apply discount, and calculate the final price — on every product, for every user. Instead of repeating those 10 lines everywhere, developers write three functions: calc_tax(), apply_discount(), final_price(). Change the tax rate once and it's correct everywhere.
Answer all questions, then click Check answers. Use this before Practice in the editor.
Q1. What keyword defines a function?
Q2. What does return do?
Q3. Why write functions?
Q4. square(5) should return…