Functions and Abstraction
Ages 16–18Difficulty adapts to you
Functions and Abstraction
A function hides internal steps behind a name. Parameters are inputs; a return value is the output. A good contract states valid inputs, units, side effects, and the expected result, making testing easier.
Your goals
- ✓You can break solutions into reusable functions with parameters, return values, and clear contracts.
- ✓You can use Functions and Abstraction, model correctly.
- ✓You can use the definitions, units, assumptions, and examples to check your answer.
Words to know
- Functions and Abstraction:
- Break solutions into reusable functions with parameters, return values, and clear contracts.
- model:
- A rule or representation used to describe a situation and make a prediction.
Examples
- 1area_of_circle(radius) returns πr² for a non-negative radius.
- 2A tax function can accept gross pay and return the deduction while keeping the rate rules in one place.
Check these
- • Do not skip the meaning of a term or give a result without explaining what it means.
- • Keep every number, symbol, label, and unit in its correct place.
- • Show enough working to check how you reached your answer.
Helpful habits
- • Read the whole question before choosing what to do.
- • Show one clear step at a time and check each step.
- • If you are stuck, draw a model, try smaller numbers, or revisit the example.
Now try your own
Create your own functions and abstraction example, solve it, and explain how you checked it.
Shield
Safety & Digital Confidence“Compare your progress to yesterday, not to others.”