数値データ型

Python のデータ型

Jason Myers

Instructor

組み込みの数値型

整数 (int)

  • 整数のみ
  • 大きな値に対応
int(123456789123456789)
123456789123456789

浮動小数点数 (float)

  • 小数を表す(近似)
  • 指数表記に対応
float(123456789123456789)
1.2345678912345678e+17
Python のデータ型

Decimal 型

  • 正確な精度
  • 通貨計算に適する
from decimal import Decimal
Decimal('123456789123456789')
Decimal('123456789123456789')
Python のデータ型

浮動小数点数の表示

print(0.00001)
1e-05
print(f"{0.00001:f}")
0.000010
Python のデータ型

浮動小数点数の表示

print(f"{0.0000001:f}")
0.000000
print(f"{0.0000001:.7f}")
0.0000001
Python のデータ型

Python の除算の種類

4/2
2.0
4//2
2
7//3
2
Python のデータ型

練習しましょう!

Python のデータ型

Preparing Video For Download...