msts 1.0.0__py3-none-any.whl
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.
- msts/__init__.py +77 -0
- msts/__main__.py +46 -0
- msts/_core.py +2534 -0
- msts/gui.py +98 -0
- msts-1.0.0.dist-info/METADATA +171 -0
- msts-1.0.0.dist-info/RECORD +10 -0
- msts-1.0.0.dist-info/WHEEL +5 -0
- msts-1.0.0.dist-info/entry_points.txt +2 -0
- msts-1.0.0.dist-info/licenses/LICENSE +21 -0
- msts-1.0.0.dist-info/top_level.txt +1 -0
msts/__init__.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
msts — Máy Tính Toán Học Thông Minh (dành cho bài tập kiểu SGK)
|
|
4
|
+
================================================================
|
|
5
|
+
Thư viện Python THUẦN CHUẨN (không cần cài thêm thư viện nào) giúp:
|
|
6
|
+
|
|
7
|
+
1) TÍNH TOÁN CHÍNH XÁC bằng phân số (không bao giờ gặp lỗi
|
|
8
|
+
0.1 + 0.2 = 0.30000000000000004):
|
|
9
|
+
>>> msts.solve("0.1 + 0.2") # -> 3/10
|
|
10
|
+
>>> msts.solve("x^2 - 5x + 6 = 0") # -> x = 2 hoặc x = 3
|
|
11
|
+
2) TRÌNH BÀY TỪNG BƯỚC GIẢI kiểu bài làm SGK:
|
|
12
|
+
>>> print(msts.steps("2 + 3*(4-1)").text)
|
|
13
|
+
3) BIẾN KÍ HIỆU NHẬP SANG DẠNG SGK:
|
|
14
|
+
>>> msts.pretty("2^10 + 8//3 + pi/2 <= 5") # -> '2¹⁰ + ∛8 + π/2 ≤ 5'
|
|
15
|
+
|
|
16
|
+
Kí hiệu khi nhập: a//b (căn bậc b), a^b (lũy thừa), pi, e, (a/b), / hoặc :,
|
|
17
|
+
< <= > >= !=, = (lập phương trình), 5!, 50%, sin/cos/tan/cot (mặc định theo độ),
|
|
18
|
+
asin..., ln, log, log2, log10, exp, sqrt, can(a[,b]), abs, floor, ceil, round,
|
|
19
|
+
gcd, lcm, min, max, mod. Module cũng ĐỌC được kí hiệu Unicode: √16, ∛8, π, ≤,
|
|
20
|
+
×, ÷, ², ½ ... (xem README.md để có bảng kí hiệu đầy đủ)
|
|
21
|
+
|
|
22
|
+
Cấu hình nhanh:
|
|
23
|
+
msts.cau_hinh(kieu_sgk=True) # xuất số kiểu SGK: 0,5 và 0,(3)
|
|
24
|
+
msts.cau_hinh(so_chu_so=15) # số chữ số thập phân (mặc định 12)
|
|
25
|
+
msts.cau_hinh(don_vi="rad") # lượng giác theo radian
|
|
26
|
+
msts.cau_hinh(ngon_ngu="en") # chú thích bước giải tiếng Anh
|
|
27
|
+
msts.cau_hinh(chi_tiet="short")
|
|
28
|
+
|
|
29
|
+
Widget GUI (TUỲ CHỌN — cần customtkinter, cài bằng: pip install msts[gui]):
|
|
30
|
+
msts.MathLabel, msts.StepsBox, msts.chon_font_toan,
|
|
31
|
+
msts.gan_xem_truc_tiep
|
|
32
|
+
"""
|
|
33
|
+
from ._core import (
|
|
34
|
+
__version__,
|
|
35
|
+
DAU_TRU,
|
|
36
|
+
VO_CUNG_AM,
|
|
37
|
+
VO_CUNG_DUONG,
|
|
38
|
+
MstsError,
|
|
39
|
+
Buoc,
|
|
40
|
+
BuocGiai,
|
|
41
|
+
KetQua,
|
|
42
|
+
Nghiem,
|
|
43
|
+
cau_hinh,
|
|
44
|
+
kieu_sgk,
|
|
45
|
+
so_chu_so,
|
|
46
|
+
don_vi,
|
|
47
|
+
ngon_ngu,
|
|
48
|
+
solve,
|
|
49
|
+
steps,
|
|
50
|
+
pretty,
|
|
51
|
+
xem_truc_tuyen,
|
|
52
|
+
chuan_hoa,
|
|
53
|
+
giai,
|
|
54
|
+
buoc_giai,
|
|
55
|
+
lam_dep,
|
|
56
|
+
to_math,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# ---- phần GUI (tuỳ chọn: thiếu customtkinter thì lõi vẫn chạy bình thường) ----
|
|
60
|
+
try:
|
|
61
|
+
from . import gui
|
|
62
|
+
from .gui import _DA_CAI_CTK, chon_font_toan, gan_xem_truc_tiep
|
|
63
|
+
if _DA_CAI_CTK:
|
|
64
|
+
from .gui import MathLabel, StepsBox
|
|
65
|
+
except Exception:
|
|
66
|
+
gui = None
|
|
67
|
+
_DA_CAI_CTK = False
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
"__version__",
|
|
71
|
+
"MstsError", "KetQua", "Nghiem", "BuocGiai", "Buoc",
|
|
72
|
+
"DAU_TRU", "VO_CUNG_AM", "VO_CUNG_DUONG",
|
|
73
|
+
"cau_hinh", "kieu_sgk", "so_chu_so", "don_vi", "ngon_ngu",
|
|
74
|
+
"solve", "steps", "pretty", "xem_truc_tuyen", "chuan_hoa",
|
|
75
|
+
"giai", "buoc_giai", "lam_dep", "to_math",
|
|
76
|
+
"chon_font_toan", "gan_xem_truc_tiep", "gui",
|
|
77
|
+
]
|
msts/__main__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Demo console của msts.
|
|
3
|
+
|
|
4
|
+
Chạy: python -m msts (hoặc gõ lệnh msts sau khi đã pip install)
|
|
5
|
+
"""
|
|
6
|
+
from ._core import KetQua, MstsError, pretty, solve, steps
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _demo_console():
|
|
10
|
+
cac_vd = [
|
|
11
|
+
"2 + 3*(4-1)",
|
|
12
|
+
"(1/2 + 1/3) : (1/6)",
|
|
13
|
+
"0.1 + 0.2",
|
|
14
|
+
"//2 * //8",
|
|
15
|
+
"(1 + //2)^2",
|
|
16
|
+
"2pi + pi",
|
|
17
|
+
"5! + 50%",
|
|
18
|
+
"sin(30) + tan(45)",
|
|
19
|
+
"2x + 3 = 7",
|
|
20
|
+
"x^2 - 5x + 6 = 0",
|
|
21
|
+
"x^2 < 4",
|
|
22
|
+
"2x - 1 >= 3",
|
|
23
|
+
]
|
|
24
|
+
for vd in cac_vd:
|
|
25
|
+
try:
|
|
26
|
+
print("\u2500" * 52)
|
|
27
|
+
print("\u25b6", vd, "\u2192", pretty(vd))
|
|
28
|
+
kq = solve(vd)
|
|
29
|
+
print("=", kq.text)
|
|
30
|
+
tp = kq.thap_phan() if isinstance(kq, KetQua) else None
|
|
31
|
+
if tp and tp != kq.text:
|
|
32
|
+
print(("\u2248" if "\u2026" in tp else "="), tp)
|
|
33
|
+
except MstsError as e:
|
|
34
|
+
print("L\u1ed7i:", e)
|
|
35
|
+
print("\u2500" * 52)
|
|
36
|
+
print("Chi ti\u1ebft m\u1ed9t b\u00e0i gi\u1ea3i:")
|
|
37
|
+
print(steps("x^2 - 5x + 6 = 0").text)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main():
|
|
41
|
+
"""Điểm vào dòng lệnh (pyproject: [project.scripts] msts = "msts.__main__:main")."""
|
|
42
|
+
_demo_console()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|