Disclaimer: This README file was written by AI that is implemented in this project.
This app is a simple calculator that can evaluate infix expressions with basic arithmetic operators (+, -, *, /). It also renders the expression and result in a box.
- Make sure you have Python installed.
- Save the
calculator.pyandrender.pyfiles in the same directory. - You will need to run the files from the command line.
To run the calculator, create a python script that uses the calculator and render functions. For example:
from pkg.calculator import Calculator
from pkg.render import render
calculator = Calculator()
expression = "1 + 2 * 3"
result = calculator.evaluate(expression)
if result is not None:
print(render(expression, result))
else:
print("Invalid expression")Save this file as main.py and run it from the command line using python main.py.
calculator.py: Defines theCalculatorclass.render.py: Defines therenderfunction.morelorem.txt: This file doesn't seem to be used by the application. It is just a text file.
The calculator evaluates expressions based on operator precedence (* and / have higher precedence than + and -).