From a655c9a5ec506bba0d0af401d140f7e19e038ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Tue, 22 Dec 2020 18:42:12 +0800 Subject: [PATCH] NICE! --- libs/P_C.py | 50 +++++++++++++++++++++----------------------------- libs/tools.py | 3 --- test.py | 6 +++--- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/libs/P_C.py b/libs/P_C.py index 6e26591..9644a5a 100644 --- a/libs/P_C.py +++ b/libs/P_C.py @@ -7,49 +7,41 @@ import libs import math -def P_C_M(A, B): # stand for Scientific notation multiple +def S_C_float_check(SC): # stand for Scientific notation's float check\ """ formats: - A & B list format:docs.basic_config.json:basic_number + SC list format:docs.basic_config.json:basic_number""" + while SC[0] >= 10: + SC[0] /= 10 + SC[1] += 1 + while SC[0] < 1: + SC[0] *= 10 + SC[1] -= 1 + + +def S_N_M(A, B): # stand for Scientific notation multiple """ - C = [0.0, 1, [], []] - Float = float(A[0] * B[0]) - Int = int(A[1] + B[1]) - if Float >= 10: - Float /= 10 - Int += 1 - elif Float <= 1: - Float *= 10 - Int -= 1 - else: - pass + formats: + A & B list format:docs.basic_config.json:basic_number""" + C = [float(A[0] * B[0]), int(A[1] + B[1])] + S_C_float_check(C) Unit1, Unit2 = A[2] + B[2], A[3] + B[3] if Unit1 == None: Unit1 = [] libs.tools.D_C(Unit1, Unit2) - C = [Float, Int, Unit1, Unit2] + C += [Unit1, Unit2] return C -def P_C_D(A, B): # stand for Physics Calculation divide +def S_N_D(A, B): # stand for Scientific notation divide """ formats: - A & B list format:docs.basic_config.json:basic_number - """ - C = [0.0, 1, [], []] - Float = float(A[0] / B[0]) - Int = int(A[1] - B[1]) - if Float >= 10: - Float /= 10 - Int += 1 - elif Float <= 0.01: - Float *= 10 - Int -= 1 - else: - pass + A & B list format:docs.basic_config.json:basic_number""" + C = [float(A[0] / B[0]), int(A[1] - B[1])] + S_C_float_check(C) Unit1, Unit2 = A[2] + B[3], A[3] + B[2] if Unit1 == None: Unit1 = [] libs.tools.D_C(Unit1, Unit2) - C = [Float, Int, Unit1, Unit2] + C += [Unit1, Unit2] return C diff --git a/libs/tools.py b/libs/tools.py index b886a80..1c3bbe3 100644 --- a/libs/tools.py +++ b/libs/tools.py @@ -28,6 +28,3 @@ def D_C(listA, listB): # stand for Duplicate check listA.sort() listB.sort() return - -def S_C_float_check(SC): # stand for Scientific notation's float check - pass \ No newline at end of file diff --git a/test.py b/test.py index 01d9ff6..e64057b 100644 --- a/test.py +++ b/test.py @@ -12,9 +12,9 @@ B = [0.245, -7, ["N", "kg"], ["m", "s"]] print("A = " , A) print("B = " , B) -C = libs.P_C.P_C_M(A, B) -D = libs.P_C.P_C_D(A, B) -E = libs.P_C.P_C_D(C, B) +C = libs.P_C.S_N_M(A, B) +D = libs.P_C.S_N_D(A, B) +E = libs.P_C.S_N_D(C, B) print("A × B = " , C) print("A ÷ B = " , D)