def test_subtract_integers(self): result = math.subtract(1, 1) self.assertEqual(result, 0)
def test_subtract_floats(self): result = math.subtract(1.0, 0.5) self.assertEqual(result, 0.5)
# 一般匯入 import math print( math.log(100, 10) ) # 計算 log(100) = 2 print( math.factorial(5) ) # 計算 5! = 120 # 一般匯入加上別名 import as import math as m print( m.add(1,3) ) print( m.subtract(1,3) ) # 匯入所有函數 from math import * print( log(100, 10) ) print( factorial(5) ) # 只匯入 log, factorial 函數 from math import log, factorial print( log(100, 10) ) print( factorial(5) ) # 一句匯入多個模組