━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 実践プログラミング:Pythonの標準ライブラリ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●例題で使うライブラリモジュール math (数学関数) https://docs.python.org/ja/3/library/math.html import math モジュール読み込み math.factorial(num) 階乗 math.sqrt(num) 平方根 math.inf 無限大 math.ceil(num) num以上の最小整数(正なら切り上げ) math.log(num) 自然対数 math.dist(point1, point2) 2点間の距離 help(math) 関数一覧 random (擬似乱数) https://docs.python.org/ja/3/library/random.html import random モジュール読み込み random.randint(m, n) mからnまでの整数の乱数 random.choice(seq) 列からの無作為抽出 help(random) 関数一覧 csv (表形式データ) https://docs.python.org/ja/3/library/csv.html import csv モジュール読み込み csv.reader(csv_file) CSVファイルをリストのリストに変換 help(csv) 関数一覧 matplotlib (視覚化) https://matplotlib.org/ plt.figure(figsize=(m,n)) 図の大きさの変更 plt.plot(xs, ys) データ列を折れ線で描画 plt.plot(xs, ys, 'o') データ列を点で描画 plt.clf() 描画の新規開始 ●課題で使えるライブラリモジュール math (数学関数) https://docs.python.org/ja/3/library/math.html math.pi 円周率 math.sin 三角関数sin math.cos 三角関数cos matplotlib (視覚化) https://matplotlib.org/ plt.title(title_string) 図の表題 plt.axis('equal') 縦横の縮尺を統一 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 実践プログラミング:Pythonプログラミング 山田 俊行 https://www.cs.info.mie-u.ac.jp/~toshi/