A simple command-line calculator built with Python.
This project supports basic arithmetic operations and includes input validation, error handling, and the ability to continue calculations using the previous result.
- ➕ Addition
- ➖ Subtraction
- ✖️ Multiplication
- ➗ Division
- 🔢 Decimal number support
- 🛡️ Input validation
⚠️ Division-by-zero protection- 🔄 Continue calculations using the previous result
- 🧹 Console clearing between sessions
- ❌ Invalid input handling
- Python 3
- Built-in
osmodule
python-calculator/
│
└── main.py
Make sure Python 3 is installed on your system.
Clone the repository:
git clone https://github.com/Ramtinexe/python-calculator.gitNavigate to the project folder:
cd python-calculatorRun the program:
python main.py-
Enter the first number.
-
Choose an operation:
+Addition-Subtraction*Multiplication/Division
-
Enter the second number.
-
The calculator displays the result.
-
Choose whether to:
- Continue calculating with the previous result.
- Start a new calculation.
This project helped me practice several Python concepts:
- Functions
- Return values
- Dictionaries
- Dictionary of functions
whileloops- Nested loops
if / elif / elsebreakandcontinuetry / except- Input validation
- Error handling
- Basic file/system operations with
os
Ramtin
GitHub: https://github.com/Ramtinexe
⭐ If you found this project useful, feel free to give it a star!