Beginner-friendly arithmetic — all five operations in one function call.
Project description
calcmate
Beginner-friendly arithmetic — all five operations in one function call.
Why calcmate?
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}
Installation
pip install calcmate
Requires Python 3.8 or higher. No dependencies.
Usage
All operations at once
from calcmate import calc
result = calc(15, 3)
print(result)
# {'add': 18, 'sub': 12, 'mul': 45, 'div': 5.0, 'floordiv': 5}
One operation at a time
calc(21, 7, '+') # 28
calc(21, 7, '-') # 14
calc(21, 7, '*') # 147
calc(21, 7, '/') # 3.0
calc(21, 7, '//') # 3
Safe division
calc(10, 0)
# {'add': 10, 'sub': 10, 'mul': 0,
# 'div': 'Cannot divide by zero',
# 'floordiv': 'Cannot divide by zero'}
API reference
calc(a, b, op=None)
| 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
Contributing
git clone https://github.com/yourusername/calcmate.git
cd calcmate
pip install -e ".[dev]"
pytest
License
MIT — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file calcmate-0.1.1.tar.gz.
File metadata
- Download URL: calcmate-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd3136b547440bedc1b009f4268174a3197edf14a5e0edcecbe20126d7024357
|
|
| MD5 |
aeb61bee7ea0f29b7b481a4f33be9c78
|
|
| BLAKE2b-256 |
b4881d692bfe242ec93364e0c5ec482783e4a74531271b638cfc26d903422b1b
|
File details
Details for the file calcmate-0.1.1-py3-none-any.whl.
File metadata
- Download URL: calcmate-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed44db57129d3f5715bc3cf0ced92a295085d7566edd53b1029eac271153d74b
|
|
| MD5 |
6d10143d209b35c7cf7682bac9136f08
|
|
| BLAKE2b-256 |
f5c0fde2a65035290b33749a755d78ba34323acd9bf6de3e223a9f643ea8b11f
|