Functions and Procedures (OCR A-Level Computer Science): Flashcards
📚Flashcards
Practise the cards
14 cards from this deck
ShowHide
Practise the cards
14 cards from this deck
Definition of a function
Definition of a function
Code block that performs a task & returns a value
Definition of a procedure
Definition of a procedure
Code block that performs a task but doesn't return a value
Key difference: function vs procedure
Key difference: function vs procedure
Functions return a value; procedures don't
When to use a function
When to use a function
When the result needs to be used elsewhere in the program
When to use a procedure
When to use a procedure
To modify data, interact with user, or output without return
How functions are typically integrated
How functions are typically integrated
Used within expressions or other functions
How procedures are typically called
How procedures are typically called
As standalone statements
Benefit: Code reusability
Benefit: Code reusability
Functions/procedures can be called multiple times, reducing duplication
Benefit: Improved readability
Benefit: Improved readability
Breaking program into smaller sections makes it easier to read
Benefit: Testing & debugging
Benefit: Testing & debugging
Individual functions/procedures can be tested independently
Benefit: Collaborative development
Benefit: Collaborative development
Team members can work on different functions/procedures
Common mistake with procedures
Common mistake with procedures
Attempting to use a RETURN statement in a procedure
Common mistake with functions
Common mistake with functions
Forgetting to store or use the returned result
Use for mathematical calculations
Use for mathematical calculations
Functions (e.g., calculateArea, findMaximum)
