Functions (Edexcel GCSE Computer Science): Flashcards
📚Flashcards
Practise the cards
12 cards from this deck
ShowHide
Practise the cards
12 cards from this deck
Function definition
Function definition
A special type of subprogram that returns a value to the code that called it
Keyword to create a function in Python
Keyword to create a function in Python
def
Parameters
Parameters
Variables that receive values passed from the main program
Local variables
Local variables
Variables created inside a function, only usable within it
Return statement purpose
Return statement purpose
Sends a result back to the main program
Calling a function
Calling a function
Executing a function after it's been defined
Arguments
Arguments
The actual values you pass TO the function
Arguments vs parameters distinction
Arguments vs parameters distinction
Arguments are sent; parameters receive inside the function
Parameter naming convention tip
Parameter naming convention tip
Start parameter names with 'p' to avoid confusion
Local scope
Local scope
Variables inside functions can't be accessed from outside
When to use functions
When to use functions
For repeated calculations, organization, or breaking problems
Common mistake with local variables
Common mistake with local variables
Trying to use them outside the function where they were created
