Skip to content

Ademfcan/SimpleCalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CustomCalc A small, customizable calculator for Python that lets you define your own operators, constants, and functions. Uses NumPy for math operations.

Install: pip install customcalc

Example:

from calculator import build_basic_calc
# default operators/expressions
calc = build_basic_calc()
print(calc.calculate("1 + 2 * 3")) # 7
print(calc.calculate("cos(pi / 3)")) # 0.5
print(calc.calculate("3! + 4")) # 10

# Custom operator example:
from calculator import CalculatorBuilder
import numpy as np

b = CalculatorBuilder()

b.addBinaryOperator("plus", 0, np.add)
b.addConstant("one", 1)
b.addConstant("two", 2)

calc = b.build()
print(calc.calculate("one plus two")) # equals three

License: MIT

About

Simple Calculator with support for custom binary and unary ops

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages