https://github.com/dplocki/calculator-kata
The full infix calculator kata, written in Python
https://github.com/dplocki/calculator-kata
calculator calculator-python code-kata infix infix-notation-calculator kata python python-3 python3 python311 reverse-polish reverse-polish-notation rpn
Last synced: 3 months ago
JSON representation
The full infix calculator kata, written in Python
- Host: GitHub
- URL: https://github.com/dplocki/calculator-kata
- Owner: dplocki
- License: gpl-3.0
- Created: 2021-10-02T13:40:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-17T18:51:32.000Z (almost 2 years ago)
- Last Synced: 2025-01-14T14:11:37.713Z (5 months ago)
- Topics: calculator, calculator-python, code-kata, infix, infix-notation-calculator, kata, python, python-3, python3, python311, reverse-polish, reverse-polish-notation, rpn
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Calculator kata



[](https://github.com/psf/black)
## 📒 Idea
The standard [String Calculator](https://codingdojo.org/kata/StringCalculator/) kata is much simpler that this one. The task is to parse the string, find all numbers and calculate the sum. There is also the [RPN calculator](https://codingdojo.org/kata/RPN/) kata, which is closer to it.
This one is the calculator, which is parsing the input (string) as [infix](https://en.wikipedia.org/wiki/Infix_notation) notated operation and return its result. In short: you can type the mathematical operation in *human way* and see the result.
## ✔️ Functionality
* adding, subtraction
* multiple, division
* negation (minus before some expression)
* power
* brackets (the round one only)
* float numbers, in simple and scientific notation
* simple validation (double operators, letters in place of numbers etc.)## ⚙️ Run
The module is ready to use:
```py
from calculator import calculateprint(calculate('32 + 45 * 34 - 23'))
```