Friday, November 14, 2025

Week 3 and 4 Learning Summary

Week 3 and 4 subject 1: Functions

  • Function is a block of code with:
    • A name,
    • Zero or more parameters,
    • Zero or more return values.
  • Functions are useful for:
    • Eliminating repetition, and
    • Simplifying code, making it easier to read.
  • The same number of parameters need to be provided when calling a Function, as the number of parameters in the definition of the function.
  • You can specify default values of parameters in the definition.  When there are default values, less parameters can be provided when calling.
  • Use the return statement to return values to the caller.  You can return multiple values:
    • In the form of a tuple, i.e., multiple values separated by commas, or
    • In a list.

No comments:

Post a Comment