Lessons 3-5
Objective: Create a Python program that functions as a simple calculator. This project will help you practice the concepts learned in Lessons 3, 4, and 5.
Components of an Effective Solution
Welcome Message:
Display a welcome message to greet the user.
User Input (Hard-coded):
Initialize variables
num1
,operator
, andnum2
with hard-coded numeric values and an operator (+
,-
,*
,/
,%
).Calculation:
Use conditional statements (if-elif-else) to perform the corresponding arithmetic operation based on the operator.
Supported operations include addition, subtraction, multiplication, division, and modulo.
Handle division by zero and modulo by zero cases with error messages.
Result Display:
Check if a valid result has been calculated.
If a valid result is available, display it in a formatted message.
Error Handling:
Provide error messages for invalid operators and division/modulo by zero errors.
Closing Message:
Display a closing message to thank the user for using the Mini Calculator.
Key Points
The project adheres to your constraints by avoiding input functions, function definitions, import statements, and try-except statements. (Concepts we will cover in the last two lessons)
It uses hard-coded values for the calculation to demonstrate the program's functionality.
The program is structured with clear sections for input, calculation, result display, error handling, and messages.
Supported arithmetic operations are included, and the code handles common error scenarios.
The project is designed to be a simple calculator for educational purposes, focusing on basic Python concepts without relying on advanced features.