Cheat sheet · Class 11 · CBSE · Science Computer Science

Functions cheat sheet

The whole chapter on one page: key formulas, facts and the points to remember, for quick revision before a test.

CBSE Class 11 · Computer Science

Cheat sheet

Chapter 7Functions

Define once with def, call many times.

1. Defining

def area(l, b=1):
    return l * b
  • Parameters (in def) vs arguments (in call).
  • Default parameters must come after non-default ones.
  • A function without return gives None.

2. Scope

  • Local: inside the function.
  • Global: outside all functions; use global keyword to modify.
  • LEGB lookup order.

3. Types of Functions

TypeExamples
Built-inlen(), abs(), max(), input(), print()
Modulemath.sqrt(), random.randint(), statistics.mean()
User-definedcreated with def

Import: import math, from math import pi, import math as m.

4. Key Points

  • Functions can return multiple values (as a tuple).
  • Flow of execution jumps to the function and back.
  • Positional arguments match by order.
  • random.random() gives [0, 1).

Remember: def & return | default params | scope | modules

Functions: questions and notes

More Class 11 · CBSE · Science Computer Science cheat sheets

Practise Functions

Sign up free to practise the full chapter. Questions you get wrong come back until you've mastered them.

Start practising free

Free to start · No credit card needed