Beginner-friendly arithmetic — all five operations in one function call.
Learning Python means dealing with a lot of syntax before you get to the interesting parts. calcmate removes the friction from basic arithmetic so beginners can focus on concepts rather than operators.
Without calcmate:
a = 21
b = 7
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a // b)With calcmate:
from calcmate import calc
print(calc(21, 7)){'add': 28, 'sub': 14, 'mul': 147, 'div': 3.0, 'floordiv': 3}
pip install calcmateRequires Python 3.8 or higher. No dependencies.
from calcmate import calc
result = calc(15, 3)
print(result)
# {'add': 18, 'sub': 12, 'mul': 45, 'div': 5.0, 'floordiv': 5}calc(21, 7, '+') # 28
calc(21, 7, '-') # 14
calc(21, 7, '*') # 147
calc(21, 7, '/') # 3.0
calc(21, 7, '//') # 3calc(10, 0)
# {'add': 10, 'sub': 10, 'mul': 0,
# 'div': 'Cannot divide by zero',
# 'floordiv': 'Cannot divide by zero'}| Parameter | Type | Description |
|---|---|---|
a |
int or float |
First operand |
b |
int or float |
Second operand |
op |
str, optional |
Operator: '+', '-', '*', '/', '//' |
Returns:
- A single
int,float, orstrwhenopis provided - A
dictwith keysadd,sub,mul,div,floordivwhenopis omitted
Raises:
TypeError— ifaorbare not numeric, oropis not a stringValueError— ifopis not one of the five supported operators
git clone https://github.com/yourusername/calcmate.git
cd calcmate
pip install -e ".[dev]"
pytestMIT — see LICENSE for details.