Notes · Class 11 · CBSE · Science Computer Science
Functions notes
Revision notes for the chapter: the key points, definitions and exam tips to remember.
A function is a named block of code that performs a task and can be reused.
ADVANTAGES
- Reusability, modularity, easier testing and reading.
DEFINING AND CALLING
- def name(parameters): … return value
- Arguments are passed when calling; parameters receive them.
TYPES OF ARGUMENTS
- Positional, default (def f(a, b=2)), keyword (f(b=3, a=1)).
RETURN
- Returns a value (or a tuple of values); without return, the function returns None.
SCOPE
- Local variables exist only inside the function.
- Global variables exist throughout; use the keyword global to change them inside a function.
TYPES OF FUNCTIONS
- Built-in (len, print, input, int, abs, max).
- Module functions: import math (sqrt, ceil, floor, pi), random (random, randint), statistics (mean, median, mode).
- User-defined.
Memory hook: "Define once, call many times."
Functions: practice questionsFunctions cheat sheet
More Class 11 · CBSE · Science Computer Science notes
Practise Functions
Sign up free to practise the full chapter after revising. Questions you get wrong come back until you've mastered them.
Start practising freeFree to start · No credit card needed