A lightweight and basic maths interpreter
Project description
mathterpreter
A lightweight and basic maths interpreter
Example usage
Basic usage
from mathterpreter import interpret
print(interpret("54-3*(2+1)-3"))
Step by step
from mathterpreter import Lexer, Parser
lexer = Lexer("54-3*(2+1)-3")
tokens = lexer.tokenize()
parser = Parser(tokens)
tree = parser.parse()
result = tree.evaluate()
print(result)
Command line
python3 -m mathterpreter 54-3*(2+1)-3
# or
echo 54-3*(2+1)-3 | python3 -m mathterpreter
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mathterpreter-1.0.2.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for mathterpreter-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0e9b9a0f110fbfef65fc42af53197f931508fea5c52ff5bc923e53250560bfa |
|
MD5 | 4e683b88f2586e63045f26c349cf074c |
|
BLAKE2b-256 | 69881ec28e14f6f9c99efd6dad77fc0bb1b29f4fa258abb09e976775fc03bbc7 |