🎯 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
whileloop 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:
- Main Menu: The program must use a
whileloop to repeatedly display a menu of options to the user (e.g., "1. Add, 2. Subtract, 3. Multiply, 4. Divide, 5. Quit"). - User Choice: The program must get the user's choice from the menu.
- Separate Functions: You must create a separate, dedicated function for each mathematical operation (
add,subtract,multiply,divide). - Parameters and Return Values: Each math function must accept two numbers as parameters and return the calculated result.
- Professional Documentation: Every function you write (including your math functions and your main program logic) must have a complete and professional docstring.
- 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:
- First, write and test just your
addfunction. - Then, write and test your
subtractfunction. - Once all your math functions are working perfectly, then build the main
whileloop for the menu. - Finally, use an
if/elif/elsechain inside your loop to call the correct function based on the user's choice.