A simple yet smart Python CLI calculator that reads a full math
expression in one line (like 12+5, 9 /3, 7* 4) --- removes
spaces, detects the operator, splits the operands, and evaluates the
result.
Built to practice:
- 🧠 Logic building
- 🔤 String parsing
- ⚙️ Control flow & operators
- 🛡 Error handling (division-by-zero)
This project is small --- but it's intentional. I wrote the logic myself instead of relying on built-in eval functions.
- ✔ Accepts full expressions in a single input
- ✔ Supports
+,-,*,/ - ✔ Automatically removes spaces
- ✔ Detects operator dynamically
- ✔ Handles division-by-zero safely
- ✔ Clean, readable, beginner-friendly code
Input
Enter Your Statements: 12 + 6
Output
Output using + Operator: 18
Input Output
7*3 21
9 / 3 3.0
15-4 11
5/0 Cant Divide by zero
- Takes full input as a single string
- Removes all spaces
- Loops through supported operators
- Splits the expression using the operator
- Converts operands to integers
- Passes values to calculation function
Keeps things:
- modular
- readable
- easy to extend later
main()
├─ rec_conv_data() → parses input & detects operator
└─ calculations() → performs operation & handles errors
Planned upgrades:
- ⏳ Support decimal / floating-point numbers
- 🧪 Add invalid-input handling
- ➕ Support exponent & modulus
- 🖥 GUI or web-based version
- ⚡ Add automated tests
Instead of copying solutions, I wanted to:
- break a problem into smaller steps
- practice parsing logic
- handle edge-cases manually
- improve problem-solving skills
Sometimes "simple" projects teach the most.
If you have ideas or improvements --- feel free to:
- open an issue
- suggest enhancements
- fork and experiment
I'm always learning & iterating 🚀