Functions and Procedues Flashcards

1
Q

What is a function and what are its characteristics?

A

A function is a self-contained block of code, that can be invoked multiple times throughout a program, its characteristics include the following:
1. Modularity: Fuctions allow code to be broken down into smaller parts that perform specific tasks
2. Reusability: Once a function is defined it can be used multiple times throughout a program
3. Input/Output: Functions take in inputs as parameters and can return output
4. Scope: Variables created within a function, can only be accessed from within that function
5. Signature: Functions have a signature that includes their: Name, Input Parameters, and the data type of the value they return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some advantages of functions?

A
  1. They make modularity possible making code more readable, maintainable and manageable
  2. They are reusable, which reduces code duplication
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the types of functions that exist?

A

There is 3 main types of functions and many others, the main three are:
1. Built-in functions: These are functions provided by a programming language or its standard libraries
2. User-defined functions: These are functions created by the programmer
3. Library functions: These are functions provided by a library that is not part of the standard libraries of the programming language
4. Other types of functions include: Recursive functions, Lambda functions, Higher-order functions, e.t.c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly