用法:import 模組
常用函式及變數:
Python math Module
import math
print(math.cos(0))
# 1.0
print(math.pi)
# 3.141592653589793
print(math.sqrt(4))
# 2.0
常用函式及模組:
Python statistics Module
import statistics as st
s = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]
print(st.mean(s))
# 5.4
print(st.median(s))
# 5.5
print(st.stdev(s))
# 2.8751811537130436
print(st.mode(s))
# 9
常用函式及模組:
Python Random Module
import random
print(random.randint(1, 100))
# 42
print(random.random())
# 0.7096887181512228
print(random.uniform(1.0, 51.5))
# 31.66860170042776
print(random.choice("GoodMorning"))
# g
說明 | 程式指令 |
---|---|
匯入模組 | import 模組(as 名稱) |
呼叫模組變數 | module.variable |
呼叫模組函式 | module.function() |