LscCalculator 0.0.1__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.
- lsccalculator-0.0.1/LICENSE +19 -0
- lsccalculator-0.0.1/PKG-INFO +39 -0
- lsccalculator-0.0.1/README.md +26 -0
- lsccalculator-0.0.1/pyproject.toml +18 -0
- lsccalculator-0.0.1/setup.cfg +4 -0
- lsccalculator-0.0.1/src/LscCalculator/NumbersCalculator.py +92 -0
- lsccalculator-0.0.1/src/LscCalculator/StringsCalculator.py +21 -0
- lsccalculator-0.0.1/src/LscCalculator/__init__.py +1 -0
- lsccalculator-0.0.1/src/LscCalculator.egg-info/PKG-INFO +39 -0
- lsccalculator-0.0.1/src/LscCalculator.egg-info/SOURCES.txt +10 -0
- lsccalculator-0.0.1/src/LscCalculator.egg-info/dependency_links.txt +1 -0
- lsccalculator-0.0.1/src/LscCalculator.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2025 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: LscCalculator
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: 计算库(整合decimal)
|
|
5
|
+
Author-email: Linsc <1344343923@qq.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# 强大的计算工具(整合decimal)
|
|
15
|
+
|
|
16
|
+
### 解决de问题
|
|
17
|
+
* 使用decimal库,防止0.1+0.2=0.30...4的局面
|
|
18
|
+
* 每个方法皆可输入多个数字,拒绝addition(1, addition(2, 3))
|
|
19
|
+
|
|
20
|
+
### 多功能
|
|
21
|
+
* 额外添加StringsCalculator
|
|
22
|
+
|
|
23
|
+
### 调用方法
|
|
24
|
+
```
|
|
25
|
+
from LscCalculator import *
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
nc / NC / NumbersCalculator : 计算数字运算的类
|
|
29
|
+
addition : 加法
|
|
30
|
+
subtraction : 减法
|
|
31
|
+
multiplication : 乘法
|
|
32
|
+
division : 除法
|
|
33
|
+
power : 乘方
|
|
34
|
+
factorial : 阶乘
|
|
35
|
+
sqrt : 开根号
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
print(nc().addition(1, 2, 3, 4))
|
|
39
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 强大的计算工具(整合decimal)
|
|
2
|
+
|
|
3
|
+
### 解决de问题
|
|
4
|
+
* 使用decimal库,防止0.1+0.2=0.30...4的局面
|
|
5
|
+
* 每个方法皆可输入多个数字,拒绝addition(1, addition(2, 3))
|
|
6
|
+
|
|
7
|
+
### 多功能
|
|
8
|
+
* 额外添加StringsCalculator
|
|
9
|
+
|
|
10
|
+
### 调用方法
|
|
11
|
+
```
|
|
12
|
+
from LscCalculator import *
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
nc / NC / NumbersCalculator : 计算数字运算的类
|
|
16
|
+
addition : 加法
|
|
17
|
+
subtraction : 减法
|
|
18
|
+
multiplication : 乘法
|
|
19
|
+
division : 除法
|
|
20
|
+
power : 乘方
|
|
21
|
+
factorial : 阶乘
|
|
22
|
+
sqrt : 开根号
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
print(nc().addition(1, 2, 3, 4))
|
|
26
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "LscCalculator"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{name="Linsc", email="1344343923@qq.com"}
|
|
10
|
+
]
|
|
11
|
+
description = "计算库(整合decimal)"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.12"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from decimal import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class NumbersCalculator:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
def addition(self, *addends):
|
|
9
|
+
self.__init__()
|
|
10
|
+
Sum = Decimal("0")
|
|
11
|
+
|
|
12
|
+
if type(addends[0]) is list:
|
|
13
|
+
addends = addends[0]
|
|
14
|
+
for addend in addends:
|
|
15
|
+
Sum += Decimal(f"{addend}")
|
|
16
|
+
|
|
17
|
+
return Sum
|
|
18
|
+
|
|
19
|
+
def subtraction(self, minuend, *subtrahends):
|
|
20
|
+
self.__init__()
|
|
21
|
+
difference = Decimal(f"{minuend}")
|
|
22
|
+
|
|
23
|
+
if type(subtrahends[0]) is list:
|
|
24
|
+
subtrahends = subtrahends[0]
|
|
25
|
+
for subtrahend in subtrahends:
|
|
26
|
+
difference -= Decimal(f"{subtrahend}")
|
|
27
|
+
|
|
28
|
+
return difference
|
|
29
|
+
|
|
30
|
+
def multiplication(self, *multipliers):
|
|
31
|
+
self.__init__()
|
|
32
|
+
product = Decimal("1")
|
|
33
|
+
|
|
34
|
+
if type(multipliers[0]) is list:
|
|
35
|
+
multipliers = multipliers[0]
|
|
36
|
+
for multiplier in multipliers:
|
|
37
|
+
product *= Decimal(f"{multiplier}")
|
|
38
|
+
|
|
39
|
+
return product
|
|
40
|
+
|
|
41
|
+
def division(self, dividend, *divisors):
|
|
42
|
+
self.__init__()
|
|
43
|
+
quotient = Decimal(f"{dividend}")
|
|
44
|
+
|
|
45
|
+
if type(divisors[0]) is list:
|
|
46
|
+
divisors = divisors[0]
|
|
47
|
+
|
|
48
|
+
for divisor in divisors:
|
|
49
|
+
try:
|
|
50
|
+
quotient = quotient / Decimal(f"{divisor}")
|
|
51
|
+
except DivisionByZero:
|
|
52
|
+
raise ZeroDivisionError(f"除数不能为零!")
|
|
53
|
+
|
|
54
|
+
return quotient
|
|
55
|
+
|
|
56
|
+
def recursive_range_sum(self, start, end):
|
|
57
|
+
if (end := Decimal(f"{end}")) <= (start := Decimal(f"{start}")):
|
|
58
|
+
return start
|
|
59
|
+
else:
|
|
60
|
+
return self.recursive_range_sum(start, end - 1) + end
|
|
61
|
+
|
|
62
|
+
def loop_range_sum(self, start, end):
|
|
63
|
+
self.__init__()
|
|
64
|
+
Sum = Decimal("0")
|
|
65
|
+
|
|
66
|
+
for addend in range(start, end + 1):
|
|
67
|
+
Sum += Decimal(f"{addend}")
|
|
68
|
+
|
|
69
|
+
return Sum
|
|
70
|
+
|
|
71
|
+
def power(self, n, p, modulo=None):
|
|
72
|
+
self.__init__()
|
|
73
|
+
product = Decimal(f"{pow(n, p, modulo)}")
|
|
74
|
+
return product
|
|
75
|
+
|
|
76
|
+
def sqrt(self, n, pow_num=2):
|
|
77
|
+
self.__init__()
|
|
78
|
+
n = Decimal(f"{n}")
|
|
79
|
+
pow_num = Decimal(f"{pow_num}")
|
|
80
|
+
return pow(n, 1 / pow_num)
|
|
81
|
+
|
|
82
|
+
def factorial(self, n):
|
|
83
|
+
if (n := Decimal(f"{n}")) <= 1:
|
|
84
|
+
return 1
|
|
85
|
+
else:
|
|
86
|
+
return n * self.factorial(n - 1)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
NC = nc = NumbersCalculator
|
|
90
|
+
|
|
91
|
+
if __name__ == '__main__':
|
|
92
|
+
print(nc().addition(1, 2, 3, 435, 23, 65, 3423458, 324, 12, 434, 542345))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class StringsCalculator:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
def addition(self, *addends):
|
|
6
|
+
self.__init__()
|
|
7
|
+
result = ""
|
|
8
|
+
|
|
9
|
+
if type(addends[0]) is list:
|
|
10
|
+
addends = addends[0]
|
|
11
|
+
|
|
12
|
+
for addend in addends:
|
|
13
|
+
result += addend
|
|
14
|
+
|
|
15
|
+
return result
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
sc = SC = StringsCalculator
|
|
19
|
+
|
|
20
|
+
if __name__ == '__main__':
|
|
21
|
+
print(sc().addition("123", "我是最棒的", "dfjik"))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from LscCalculator.NumbersCalculator import *
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: LscCalculator
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: 计算库(整合decimal)
|
|
5
|
+
Author-email: Linsc <1344343923@qq.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# 强大的计算工具(整合decimal)
|
|
15
|
+
|
|
16
|
+
### 解决de问题
|
|
17
|
+
* 使用decimal库,防止0.1+0.2=0.30...4的局面
|
|
18
|
+
* 每个方法皆可输入多个数字,拒绝addition(1, addition(2, 3))
|
|
19
|
+
|
|
20
|
+
### 多功能
|
|
21
|
+
* 额外添加StringsCalculator
|
|
22
|
+
|
|
23
|
+
### 调用方法
|
|
24
|
+
```
|
|
25
|
+
from LscCalculator import *
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
nc / NC / NumbersCalculator : 计算数字运算的类
|
|
29
|
+
addition : 加法
|
|
30
|
+
subtraction : 减法
|
|
31
|
+
multiplication : 乘法
|
|
32
|
+
division : 除法
|
|
33
|
+
power : 乘方
|
|
34
|
+
factorial : 阶乘
|
|
35
|
+
sqrt : 开根号
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
print(nc().addition(1, 2, 3, 4))
|
|
39
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/LscCalculator/NumbersCalculator.py
|
|
5
|
+
src/LscCalculator/StringsCalculator.py
|
|
6
|
+
src/LscCalculator/__init__.py
|
|
7
|
+
src/LscCalculator.egg-info/PKG-INFO
|
|
8
|
+
src/LscCalculator.egg-info/SOURCES.txt
|
|
9
|
+
src/LscCalculator.egg-info/dependency_links.txt
|
|
10
|
+
src/LscCalculator.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
LscCalculator
|