NICE! muti num!

This commit is contained in:
沈瑗杰 2020-12-27 22:42:55 +08:00
parent e6b7722b78
commit 98305d0666
2 changed files with 30 additions and 16 deletions

View File

@ -23,24 +23,26 @@ def S_C_float_check(SC): # stand for Scientific notation's float check
SC[1] -= 1 SC[1] -= 1
def S_N_M(A, B, *C): # stand for Scientific notation multiple def S_N_M(*SN): # stand for Scientific notation multiple
""" """
formats: formats:
A & B & C list format:docs.basic_config.json:basic_number""" A & B & C list format:docs.basic_config.json:basic_number"""
AB = __S_N_M(A, B) if len(SN) < 2:
if C: raise TypeError("it need more than 2!")
for SN in C: elif len(SN) == 2:
AB = __S_N_M(AB, SN) return __S_N_M(SN[0], SN[1])
else: else:
return AB R = __S_N_M(SN[0], SN[1])
return AB for A in SN[2:]:
R = __S_N_M(R, A)
return R
def __S_N_M(A, B): def __S_N_M(A, B):
""" """
formats: formats:
A & B list format:docs.basic_config.json:basic_number""" A & B list format:docs.basic_config.json:basic_number"""
R = [F_Mu(A[0], B[0]), F_A(A[1], B[1])] R = [F_Mu(A[0], B[0]), A[1] + B[1]]
S_C_float_check(R) S_C_float_check(R)
Unit1, Unit2 = A[2] + B[2], A[3] + B[3] Unit1, Unit2 = A[2] + B[2], A[3] + B[3]
if Unit1 == None: if Unit1 == None:
@ -54,7 +56,7 @@ def S_N_D(A, B): # stand for Scientific notation divided
""" """
formats: formats:
A & B list format:docs.basic_config:basic_number""" A & B list format:docs.basic_config:basic_number"""
R = [F_D(A[0], B[0]), F_Mi(A[1], B[1])] R = [F_D(A[0], B[0]), A[1] - B[1]]
S_C_float_check(R) S_C_float_check(R)
Unit1, Unit2 = A[2] + B[3], A[3] + B[2] Unit1, Unit2 = A[2] + B[3], A[3] + B[2]
if Unit1 == None: if Unit1 == None:
@ -73,5 +75,5 @@ def G_C(M, m, R, G): #stand for gravity calculation
G : Gravitational constant G : Gravitational constant
M & m & R format: docs.basic_config:basic_number M & m & R format: docs.basic_config:basic_number
""" """
A = S_N_M pass

24
test.py
View File

@ -8,14 +8,26 @@ import libs
A = [2.573, 3, ["m", "kg"], ["N", "s"]] A = [2.573, 3, ["m", "kg"], ["N", "s"]]
B = [2.45, -7, ["N", "kg"], ["m", "s"]] B = [2.45, -7, ["N", "kg"], ["m", "s"]]
C = [1.14, 5, ["m"], ["s"]]
D = [1.419, -4, ["kg"], ["m"]]
print("A = " , A) print("A = " , A)
print("B = " , B) print("B = " , B)
print("C = " , C)
print("D = " , D)
C = libs.P_C.S_N_M(A, B) a = libs.P_C.S_N_M(A, B)
D = libs.P_C.S_N_D(A, B) b = libs.P_C.S_N_D(A, B)
E = libs.P_C.S_N_D(C, B) c = libs.P_C.S_N_M(b, B)
d = libs.P_C.S_N_D(a, B)
print("A × B = " , C) print("A × B = " , a)
print("A ÷ B = " , D) print("A ÷ B = " , b)
print("A × B ÷ B = " , E) print("A × B ÷ B = ", c)
print("A ÷ B × B = ", d)
e = libs.P_C.S_N_M(A, B, C, D)
f = libs.P_C.S_N_M(A,libs.P_C.S_N_M(B,libs.P_C.S_N_M(C, D)))
print("A * B * C * D = " , e)
print("A * B * C * D = " , f)