Exercises — Outcome 6: Functions and Modularity
1 hands-on tasks. Do them in order; each one feeds the Canvas item it names.
35 min · hands-on
1. Calculator Functions
- Write four functions: add(a, b), subtract(a, b), multiply(a, b), divide(a, b).
- Each function must return the result; divide must handle division by zero with a message.
- Write a main() function that prompts the user for two numbers and an operation, calls the correct function, and prints the result.
Turn in / bring: Python script with all five functions and test output submitted to Canvas.