數值資料型別

Python 的資料型別

Jason Myers

Instructor

內建數值型別

Integer

  • 整數
  • 可表大數
int(123456789123456789)
123456789123456789

Float

  • 小數(近似值)
  • 科學記號
float(123456789123456789)
1.2345678912345678e+17
Python 的資料型別

Decimals

  • 精確小數
  • 貨幣運算
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...