A clean, beginner-friendly console-based calculator built with Python. This project performs basic arithmetic operations — addition, subtraction, multiplication, and division — while handling common errors gracefully.
Perfect for learning core Python concepts like user input, conditionals, loops, type conversion, and basic error handling.
- Add, subtract, multiply, and divide two numbers
- Supports both integers and decimal (floating-point) numbers
- Prevents division by zero with a friendly error message
- Handles invalid inputs (e.g., letters instead of numbers)
- Option to perform multiple calculations in one session
input()andprint()- Type conversion (
int()) - Conditional statements (
if-elif-else) - Loops (
while) - Error handling (
try-except,ValueError,ZeroDivisionError) - f-strings and output formatting
- Basic program flow and user experience
- Make sure you have Python 3 installed
- Clone or download this repository
- Open terminal/command prompt in the project folder
- Run the script:
python calculator.py(Or whatever you named the file — e.g., python main.py)
Enter first number: 15.5
Enter second number: 4
Choose operation (+, -, *, /): /
15.5 / 4 = 3.875
Do you want to calculate again? (y/n): n
Thanks for using the calculator!
- Add support for more operations (%, **, sqrt)
- Include a calculation history
- Build a GUI version with Tkinter
- Add keyboard shortcuts or menu navigation
MIT License — feel free to use, modify, and share!
Made with love by [Your Name] — learning Python one project at a time!
Happy coding!