This is a fully-featured Python calculator built for the CodingUnited Challenge 2. It runs in the terminal and supports full math expressions, scientific notation, advanced math functions, and even fun Easter egg commands!
- Supports full expressions (e.g.,
3 + 4 * 2,(5 + 2) * 3) - Handles order of operations, parentheses, exponents (
^or**) - Uses built-in math functions:
sqrt(),sin(),cos(),tan() - Constants like
pi,e - Scientific notation (
1e-3 + 2.5e2) - Use
ansto reference the previous result
| Command | Description |
|---|---|
help |
Show command and usage instructions |
clear |
Clear memory and history |
history |
Show past calculations |
exit |
Exit the calculator |
| Command | Result |
|---|---|
flip a coin |
๐ช Heads or Tails |
roll a die |
๐ฒ Random number 1โ6 |
magic 8-ball |
๐ฑ Random yes/no style answer |
- Clean prompts and user-friendly messages
- Colored output using
colorama - Rounded results (4 decimal places)
- Saves full history to
calc_history.txtwith timestamps
| File | Purpose |
|---|---|
calculator.py |
Main calculator script |
calc_history.txt |
Auto-generated log of sessions |
README.md |
Project overview and instructions |
- Python 3.x
- colorama library (install with
pip install colorama)
python calculator.py