Functions with parameters

Previously, we looked at how to pass data into functions using parameters and how to return a value from a function.

This demonstration shows this in action with the input-process-output example:


Exercise

Write these functions:

  1. inputData() - this function will input a number from the user and return it.
  2. processData(number) - this function will see if the number is divisible by 7 without a remainder and if it is it will return True otherwise false.

    Tip - use the integer division // and the remainder % operators for this.

  3. outputData(result) - this function will input the value from the previous function and print a user friendly message at the screen.

  4. main() - this function will call the three functions above to run the whole program

Here is an example of a test run.

Exercise test run