StayTalentReady

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

  1. Write four functions: add(a, b), subtract(a, b), multiply(a, b), divide(a, b).
  2. Each function must return the result; divide must handle division by zero with a message.
  3. 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.
← Outcome 5Outcome 7 →

↑ Back to top