Remrinのpython攻略日記

python3に入門しました。python3についてあれこれとサンプルコードとか。

2017-05-25から1日間の記事一覧

クラス

クラスについて。 クラスとは クラス…オブジェクトの設計図のようなもの。 データとメソッドを持つ。 インスタンス…設計図から作られた実体。オブジェクト ・クラス名は大文字で始める。 class Color_test(): pass a = Color_test() print(a) # <__main__.Color_test object at 0x....> a.red = 255</__main__.color_test>…

decimal

decimalモジュールのDecimalクラスは数値演算での誤差を回避するクラス。 小数の計算では誤差が生じる。 for i in range(10): print(i * 0.1) # 0.0 # 0.1 # 0.2 # 0.30000000000000004 # 0.4 # 0.5 # 0.6000000000000001 # 0.7000000000000001 # 0.8 # 0.9 …