Introduction to Computer Science/4.9 Major Assessment - "Simple Calculator" Project

4.9 Major Assessment - "Simple Calculator" Project

🎯 Project Goals
  • Apply your knowledge of functions, parameters, and return values to build a complete application.
  • Write clean, modular, and reusable code by separating logic into different functions.
  • Practice writing professional documentation for every function you create.
  • Use a while loop to create a menu-driven user experience.

Major Assessment: "Simple Calculator" Project (10%)

This is your major project for Unit 4. You will synthesize all the skills you've learned to build a functional, menu-driven calculator. This project will test not just your ability to write code, but your ability to organize it professionally using functions.

Core Requirements

Your program must meet the following criteria:

  1. Main Menu: The program must use a while loop to repeatedly display a menu of options to the user (e.g., "1. Add, 2. Subtract, 3. Multiply, 4. Divide, 5. Quit").
  2. User Choice: The program must get the user's choice from the menu.
  3. Separate Functions: You must create a separate, dedicated function for each mathematical operation (add, subtract, multiply, divide).
  4. Parameters and Return Values: Each math function must accept two numbers as parameters and return the calculated result.
  5. Professional Documentation: Every function you write (including your math functions and your main program logic) must have a complete and professional docstring.
  6. Quit Option: The menu loop must have a clear exit condition (e.g., if the user chooses "5", the loop terminates and the program ends).

Ideas for Extensions (Level 4+)

  • Add more advanced operations, each in their own function (e.g., exponent, square root).
  • Add robust error handling. What happens if the user tries to divide by zero? What if they enter letters instead of a menu choice?

Submission

Submit your final, working .py file or URL to the "Unit 4 Simple Calculator Project" Assignment folder in D2L.

Strategy for Success: Build It in Pieces

Don't try to build the whole thing at once! Follow these steps:

  1. First, write and test just your add function.
  2. Then, write and test your subtract function.
  3. Once all your math functions are working perfectly, then build the main while loop for the menu.
  4. Finally, use an if/elif/else chain inside your loop to call the correct function based on the user's choice.