mymathkit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mymathkit-0.1.0/PKG-INFO +79 -0
- mymathkit-0.1.0/README.md +65 -0
- mymathkit-0.1.0/pyproject.toml +26 -0
- mymathkit-0.1.0/setup.cfg +4 -0
- mymathkit-0.1.0/src/mymathkit/__init__.py +30 -0
- mymathkit-0.1.0/src/mymathkit/calculator.py +36 -0
- mymathkit-0.1.0/src/mymathkit/converter.py +39 -0
- mymathkit-0.1.0/src/mymathkit.egg-info/PKG-INFO +79 -0
- mymathkit-0.1.0/src/mymathkit.egg-info/SOURCES.txt +10 -0
- mymathkit-0.1.0/src/mymathkit.egg-info/dependency_links.txt +1 -0
- mymathkit-0.1.0/src/mymathkit.egg-info/requires.txt +3 -0
- mymathkit-0.1.0/src/mymathkit.egg-info/top_level.txt +1 -0
mymathkit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mymathkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 一个简单的数学工具包:四则运算与常用单位换算
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: math,calculator,converter
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
14
|
+
|
|
15
|
+
# mymathkit
|
|
16
|
+
|
|
17
|
+
一个用 src 布局组织的简单数学工具包,提供四则运算和常用单位换算。
|
|
18
|
+
|
|
19
|
+
## 目录结构
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
mymathkit_project/
|
|
23
|
+
├── pyproject.toml
|
|
24
|
+
├── README.md
|
|
25
|
+
└── src/
|
|
26
|
+
└── mymathkit/
|
|
27
|
+
├── __init__.py
|
|
28
|
+
├── calculator.py
|
|
29
|
+
└── converter.py
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cd D:\python_projects\mymathkit_project
|
|
36
|
+
pip install -e .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使用
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from mymathkit import add, divide, average
|
|
43
|
+
from mymathkit import celsius_to_fahrenheit, km_to_miles
|
|
44
|
+
|
|
45
|
+
print(add(1, 2)) # 3
|
|
46
|
+
print(divide(10, 4)) # 2.5
|
|
47
|
+
print(average([80, 90, 100])) # 90.0
|
|
48
|
+
print(celsius_to_fahrenheit(100)) # 212.0
|
|
49
|
+
print(km_to_miles(10)) # 6.2137
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 模块说明
|
|
53
|
+
|
|
54
|
+
### calculator
|
|
55
|
+
|
|
56
|
+
| 函数 | 说明 |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `add(a, b)` | 加法 |
|
|
59
|
+
| `subtract(a, b)` | 减法 |
|
|
60
|
+
| `multiply(a, b)` | 乘法 |
|
|
61
|
+
| `divide(a, b)` | 除法,除数为 0 时抛出 `ZeroDivisionError` |
|
|
62
|
+
| `power(base, exp)` | 幂运算 |
|
|
63
|
+
| `average(values)` | 平均值,空序列抛出 `ValueError` |
|
|
64
|
+
|
|
65
|
+
### converter
|
|
66
|
+
|
|
67
|
+
| 函数 | 说明 |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `celsius_to_fahrenheit(c)` | 摄氏度转华氏度 |
|
|
70
|
+
| `fahrenheit_to_celsius(f)` | 华氏度转摄氏度 |
|
|
71
|
+
| `celsius_to_kelvin(c)` | 摄氏度转开尔文 |
|
|
72
|
+
| `km_to_miles(km)` | 千米转英里 |
|
|
73
|
+
| `miles_to_km(mi)` | 英里转千米 |
|
|
74
|
+
| `kg_to_pounds(kg)` | 千克转磅 |
|
|
75
|
+
| `pounds_to_kg(lb)` | 磅转千克 |
|
|
76
|
+
|
|
77
|
+
## 许可证
|
|
78
|
+
|
|
79
|
+
MIT
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# mymathkit
|
|
2
|
+
|
|
3
|
+
一个用 src 布局组织的简单数学工具包,提供四则运算和常用单位换算。
|
|
4
|
+
|
|
5
|
+
## 目录结构
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
mymathkit_project/
|
|
9
|
+
├── pyproject.toml
|
|
10
|
+
├── README.md
|
|
11
|
+
└── src/
|
|
12
|
+
└── mymathkit/
|
|
13
|
+
├── __init__.py
|
|
14
|
+
├── calculator.py
|
|
15
|
+
└── converter.py
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd D:\python_projects\mymathkit_project
|
|
22
|
+
pip install -e .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 使用
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from mymathkit import add, divide, average
|
|
29
|
+
from mymathkit import celsius_to_fahrenheit, km_to_miles
|
|
30
|
+
|
|
31
|
+
print(add(1, 2)) # 3
|
|
32
|
+
print(divide(10, 4)) # 2.5
|
|
33
|
+
print(average([80, 90, 100])) # 90.0
|
|
34
|
+
print(celsius_to_fahrenheit(100)) # 212.0
|
|
35
|
+
print(km_to_miles(10)) # 6.2137
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 模块说明
|
|
39
|
+
|
|
40
|
+
### calculator
|
|
41
|
+
|
|
42
|
+
| 函数 | 说明 |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `add(a, b)` | 加法 |
|
|
45
|
+
| `subtract(a, b)` | 减法 |
|
|
46
|
+
| `multiply(a, b)` | 乘法 |
|
|
47
|
+
| `divide(a, b)` | 除法,除数为 0 时抛出 `ZeroDivisionError` |
|
|
48
|
+
| `power(base, exp)` | 幂运算 |
|
|
49
|
+
| `average(values)` | 平均值,空序列抛出 `ValueError` |
|
|
50
|
+
|
|
51
|
+
### converter
|
|
52
|
+
|
|
53
|
+
| 函数 | 说明 |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `celsius_to_fahrenheit(c)` | 摄氏度转华氏度 |
|
|
56
|
+
| `fahrenheit_to_celsius(f)` | 华氏度转摄氏度 |
|
|
57
|
+
| `celsius_to_kelvin(c)` | 摄氏度转开尔文 |
|
|
58
|
+
| `km_to_miles(km)` | 千米转英里 |
|
|
59
|
+
| `miles_to_km(mi)` | 英里转千米 |
|
|
60
|
+
| `kg_to_pounds(kg)` | 千克转磅 |
|
|
61
|
+
| `pounds_to_kg(lb)` | 磅转千克 |
|
|
62
|
+
|
|
63
|
+
## 许可证
|
|
64
|
+
|
|
65
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mymathkit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "一个简单的数学工具包:四则运算与常用单位换算"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
keywords = ["math", "calculator", "converter"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
dev = ["pytest>=8"]
|
|
21
|
+
|
|
22
|
+
[tool.setuptools]
|
|
23
|
+
package-dir = { "" = "src" }
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""mymathkit:简单数学工具包。"""
|
|
2
|
+
|
|
3
|
+
from .calculator import add, average, divide, multiply, power, subtract
|
|
4
|
+
from .converter import (
|
|
5
|
+
celsius_to_fahrenheit,
|
|
6
|
+
celsius_to_kelvin,
|
|
7
|
+
fahrenheit_to_celsius,
|
|
8
|
+
kg_to_pounds,
|
|
9
|
+
km_to_miles,
|
|
10
|
+
miles_to_km,
|
|
11
|
+
pounds_to_kg,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"add",
|
|
18
|
+
"subtract",
|
|
19
|
+
"multiply",
|
|
20
|
+
"divide",
|
|
21
|
+
"power",
|
|
22
|
+
"average",
|
|
23
|
+
"celsius_to_fahrenheit",
|
|
24
|
+
"fahrenheit_to_celsius",
|
|
25
|
+
"celsius_to_kelvin",
|
|
26
|
+
"km_to_miles",
|
|
27
|
+
"miles_to_km",
|
|
28
|
+
"kg_to_pounds",
|
|
29
|
+
"pounds_to_kg",
|
|
30
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""calculator 模块:四则运算与基础统计。"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def add(a, b):
|
|
5
|
+
"""返回 a + b。"""
|
|
6
|
+
return a + b
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def subtract(a, b):
|
|
10
|
+
"""返回 a - b。"""
|
|
11
|
+
return a - b
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def multiply(a, b):
|
|
15
|
+
"""返回 a * b。"""
|
|
16
|
+
return a * b
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def divide(a, b):
|
|
20
|
+
"""返回 a / b,除数为 0 时抛出 ZeroDivisionError。"""
|
|
21
|
+
if b == 0:
|
|
22
|
+
raise ZeroDivisionError("除数不能为 0")
|
|
23
|
+
return a / b
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def power(base, exp):
|
|
27
|
+
"""返回 base 的 exp 次方。"""
|
|
28
|
+
return base ** exp
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def average(values):
|
|
32
|
+
"""返回序列的平均值,空序列抛出 ValueError。"""
|
|
33
|
+
values = list(values)
|
|
34
|
+
if not values:
|
|
35
|
+
raise ValueError("序列不能为空")
|
|
36
|
+
return sum(values) / len(values)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""converter 模块:常用单位换算。"""
|
|
2
|
+
|
|
3
|
+
KM_PER_MILE = 1.609344
|
|
4
|
+
KG_PER_POUND = 0.45359237
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def celsius_to_fahrenheit(c):
|
|
8
|
+
"""摄氏度 -> 华氏度。"""
|
|
9
|
+
return c * 9 / 5 + 32
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def fahrenheit_to_celsius(f):
|
|
13
|
+
"""华氏度 -> 摄氏度。"""
|
|
14
|
+
return (f - 32) * 5 / 9
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def celsius_to_kelvin(c):
|
|
18
|
+
"""摄氏度 -> 开尔文。"""
|
|
19
|
+
return c + 273.15
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def km_to_miles(km):
|
|
23
|
+
"""千米 -> 英里。"""
|
|
24
|
+
return km / KM_PER_MILE
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def miles_to_km(mi):
|
|
28
|
+
"""英里 -> 千米。"""
|
|
29
|
+
return mi * KM_PER_MILE
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def kg_to_pounds(kg):
|
|
33
|
+
"""千克 -> 磅。"""
|
|
34
|
+
return kg / KG_PER_POUND
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def pounds_to_kg(lb):
|
|
38
|
+
"""磅 -> 千克。"""
|
|
39
|
+
return lb * KG_PER_POUND
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mymathkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 一个简单的数学工具包:四则运算与常用单位换算
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: math,calculator,converter
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
14
|
+
|
|
15
|
+
# mymathkit
|
|
16
|
+
|
|
17
|
+
一个用 src 布局组织的简单数学工具包,提供四则运算和常用单位换算。
|
|
18
|
+
|
|
19
|
+
## 目录结构
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
mymathkit_project/
|
|
23
|
+
├── pyproject.toml
|
|
24
|
+
├── README.md
|
|
25
|
+
└── src/
|
|
26
|
+
└── mymathkit/
|
|
27
|
+
├── __init__.py
|
|
28
|
+
├── calculator.py
|
|
29
|
+
└── converter.py
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cd D:\python_projects\mymathkit_project
|
|
36
|
+
pip install -e .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使用
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from mymathkit import add, divide, average
|
|
43
|
+
from mymathkit import celsius_to_fahrenheit, km_to_miles
|
|
44
|
+
|
|
45
|
+
print(add(1, 2)) # 3
|
|
46
|
+
print(divide(10, 4)) # 2.5
|
|
47
|
+
print(average([80, 90, 100])) # 90.0
|
|
48
|
+
print(celsius_to_fahrenheit(100)) # 212.0
|
|
49
|
+
print(km_to_miles(10)) # 6.2137
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 模块说明
|
|
53
|
+
|
|
54
|
+
### calculator
|
|
55
|
+
|
|
56
|
+
| 函数 | 说明 |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `add(a, b)` | 加法 |
|
|
59
|
+
| `subtract(a, b)` | 减法 |
|
|
60
|
+
| `multiply(a, b)` | 乘法 |
|
|
61
|
+
| `divide(a, b)` | 除法,除数为 0 时抛出 `ZeroDivisionError` |
|
|
62
|
+
| `power(base, exp)` | 幂运算 |
|
|
63
|
+
| `average(values)` | 平均值,空序列抛出 `ValueError` |
|
|
64
|
+
|
|
65
|
+
### converter
|
|
66
|
+
|
|
67
|
+
| 函数 | 说明 |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `celsius_to_fahrenheit(c)` | 摄氏度转华氏度 |
|
|
70
|
+
| `fahrenheit_to_celsius(f)` | 华氏度转摄氏度 |
|
|
71
|
+
| `celsius_to_kelvin(c)` | 摄氏度转开尔文 |
|
|
72
|
+
| `km_to_miles(km)` | 千米转英里 |
|
|
73
|
+
| `miles_to_km(mi)` | 英里转千米 |
|
|
74
|
+
| `kg_to_pounds(kg)` | 千克转磅 |
|
|
75
|
+
| `pounds_to_kg(lb)` | 磅转千克 |
|
|
76
|
+
|
|
77
|
+
## 许可证
|
|
78
|
+
|
|
79
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/mymathkit/__init__.py
|
|
4
|
+
src/mymathkit/calculator.py
|
|
5
|
+
src/mymathkit/converter.py
|
|
6
|
+
src/mymathkit.egg-info/PKG-INFO
|
|
7
|
+
src/mymathkit.egg-info/SOURCES.txt
|
|
8
|
+
src/mymathkit.egg-info/dependency_links.txt
|
|
9
|
+
src/mymathkit.egg-info/requires.txt
|
|
10
|
+
src/mymathkit.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mymathkit
|