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!