Enhance README with usage and operations
This commit is contained in:
parent
0b1f5864f7
commit
3aec070640
1 changed files with 39 additions and 12 deletions
47
README.md
47
README.md
|
|
@ -1,21 +1,48 @@
|
|||
|
||||
# Scientific Calculator
|
||||
|
||||
A simple scientific calculator built in Python.
|
||||
An interactive **command-line** scientific calculator written in Python. It presents a numbered menu, reads your inputs, and prints results for each operation. The core math lives in small functions in `calculator.py`, so you can also import them from another script if you want to reuse the same behavior.
|
||||
|
||||
## Features
|
||||
- Basic arithmetic operations
|
||||
- Trigonometric functions
|
||||
- Logarithms and exponentials
|
||||
## What it does
|
||||
|
||||
- Runs a **REPL-style loop**: choose an operation, enter operands, see `Result: …`, repeat until you exit.
|
||||
- Uses only the **Python standard library** (`math`); no extra packages to install.
|
||||
- **Validates** some edge cases: division by zero and logarithms of non-positive numbers raise clear errors instead of failing silently.
|
||||
|
||||
## Operations
|
||||
|
||||
| Choice | Operation | Inputs | Notes |
|
||||
|--------|-----------|--------|--------|
|
||||
| 1 | Add | `x`, `y` | |
|
||||
| 2 | Subtract | `x`, `y` | |
|
||||
| 3 | Multiply | `x`, `y` | |
|
||||
| 4 | Divide | `x`, `y` | Error if `y` is zero |
|
||||
| 5 | Sine | `x` | `x` is in **radians** |
|
||||
| 6 | Cosine | `x` | **radians** |
|
||||
| 7 | Tangent | `x` | **radians** |
|
||||
| 8 | Logarithm | `x`, optional base | `x` must be **> 0**; base defaults to **e** if you press Enter |
|
||||
| 9 | Exponent | `x`, `y` | `x` to the power `y` (`math.pow`) |
|
||||
| 0 | Exit | — | Ends the program |
|
||||
|
||||
Invalid menu choices print `Invalid choice.` Other problems (bad numeric input, domain errors) print `Error: …` with the exception message.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python 3 (any recent 3.x is fine)
|
||||
|
||||
## Usage
|
||||
1. Run the calculator:
|
||||
```
|
||||
|
||||
From the project directory:
|
||||
|
||||
```bash
|
||||
python calculator.py
|
||||
```
|
||||
|
||||
## Files
|
||||
- `calculator.py` — Main calculator script
|
||||
Follow the on-screen prompts. For logarithms, leave the base blank to use the natural logarithm (base **e**).
|
||||
|
||||
## Project layout
|
||||
|
||||
- **`calculator.py`** — Menu-driven `main()` plus the operation functions (`add`, `subtract`, `multiply`, `divide`, `sine`, `cosine`, `tangent`, `logarithm`, `exponent`).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
For learning purposes.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue