# Python - 基本資料類型 ###### tags: `python` `九年級` ***Python是一種廣泛使用的直譯式、高階和通用的程式語言*** ## 一、資料類型 + 最基礎的四個基本資料類型,往後的資料運算與處理都會用到 | 資料類型 | 說明 |範例| |:------:|:-----------|:-----------| |布林(`bool`)|主要用於條件判斷與邏輯運算|`True` , `False`| |整數(`int`)| 整數數值 |`42`,`1000000000`,`0`,`-9999` | |浮點數(`float`)|有小數點的數值|`3.15686`,`1.0e8`| |字串(`str`)|一串文字字元,用==單引號==或者==雙引號==包住|`"你好"` `'Hello world'`| ## 二、 type() + 檢視資料類型的內建函數 ### 範例 2-1 ```python= print( type(901 ) ) print( type(901.0) ) print( type('901') ) print( type(True ) ) ``` 輸出結果: ><class 'int'> ><class 'float'> ><class 'str'> ><class 'bool'> 可以看出 ==**901**== 為 ==**整數(int)**== 可以看出 ==**901.0**== 為 ==**浮點數(float)**== 可以看出 ==**'901'**== 為 ==**字串(str)**== 可以看出 ==**True**== 為 ==**布林(bool)**==
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up