A simple interactive command-line calculator in Python with memory, error handling, and extended math operations.
This is a simple command-line calculator built in Python. It goes beyond the basic + - × ÷
operations by including:
- Exponentiation (x^y)
- Square root
- A memory feature to reuse the last result
- Error handling to prevent crashes from invalid inputs
The calculator is interactive: after each calculation, it shows a menu and lets the user continue until they type "exit"
.
Many beginner calculators stop after a single calculation, forcing the user to restart the program. I wanted to create a lightweight, user-friendly calculator that feels more like a real tool:
- Continuous usage (menu repeats).
- Stores past results (memory).
- Gracefully handles errors (e.g., letters instead of numbers, division by zero).
This project demonstrates modular programming, error handling, and user interaction design in Python.
Addition, subtraction, multiplication, division
Power function (x^y)
Square root function
Memory (reuse last result by typing mem
)
Type "exit"
anytime to quit
Error handling for invalid inputs
- Clone the repository:
git clone https://github.com/your-username/python-interactive-calculator.git cd python-interactive-calculator