Advanced Calculator with Continuity , Clear/Back button, Restart button and Exit button. All using Python
This is an advanced calculator program built in Python that allows users to perform basic arithmetic operations such as addition, subtraction, multiplication, division, and modulus. The program features a user-friendly interface that supports various commands to clear inputs, restart the calculator, or exit the program.
- Basic Operations: Perform addition, subtraction, multiplication, division, and modulus.
- Input Flexibility: Enter commands to clear inputs or restart the calculator.
- Dynamic Result Usage: Option to use the result of the last calculation in subsequent operations.
- Error Handling: Validates inputs to ensure they are numbers, providing user-friendly error messages.
- Python 3.x installed on your machine.
-
Clone the Repository:
git clone https://github.com/your-username/advanced-calculator.git cd advanced-calculator
-
Run the Program: Open your terminal and execute:
python calculator.py
-
Follow the Prompts:
- Enter numbers when prompted.
- Choose an operation (+, -, *, /, %).
- After seeing the result, you can choose to use it in the next calculation, go back to the operation step, restart the calculator, or exit.
- C: Clear the current input and return to the first step.
- CC: Restart the entire calculator session.
- Y: Use the result of the last calculation as the first number for the next operation.
- N: Exit the program.
- Enter
10
when prompted for the first number. - Choose
+
as the operation. - Enter
5
as the second number. - The program will display the result:
10 + 5 = 15
. - You can choose to use the result in the next calculation by entering
Y
, or restart withCC
, etc.
The program ensures that:
- Non-numeric inputs are handled gracefully with prompts for valid numbers.
- Division by zero is explicitly checked and handled.
Feel free to contribute to the project by forking the repository and submitting a pull request with your improvements.