--- title: 社課共筆 - 蛇年就來學 Python 吧!(上) description: 從介紹 Google Colab 開發環境,再進入到基礎的 Python,例如:輸出/入、變數宣告、資料型態、數學、邏輯運算、條件判斷,在中途利用問題練習來加深對本次課堂的印象,並和 C語言 的語法作比較。 tags: - 社課 - 共筆 - 113 學年 --- :::success # 蛇年就來學 Python 吧!(上) **時間:** 2025/02/27(星期一)18:00~20:00 **地點:** 挺生大樓 A3-200 教室 **簡報:** [連結](https://www.canva.com/design/DAGeacDaUtc/0UVrt6Fm9mQ9fQGOygm7NA/view?utm_content=DAGeacDaUtc&utm_campaign=designshare&utm_medium=link2&utm_source=uniquelinks&utlId=hbc24679e33) **Slido:** [連結](https://app.sli.do/event/4TW296oA3oAEFayFQBJsK1/live/questions) ::: # 開發環境 ## 線上 - Google colab - 其他IDE ## 本機 - Vscode擴充Jupyter - PyCharm # Python 的特點 - 直譯式 - 高階語言 - 簡潔 - 龐大的內建函式庫 # 變數宣告 - 不能是保留字、關鍵字 - 第一個字元不能是數字 - 分大小寫 # 資料型態 ### python - 動態型別:變數會因儲存的東西不同變成不同的資料型態 ### c 語言 - 靜態型別:宣告時是甚麼型態就是甚麼型態 # 輸出/入 ### 輸出 ```python print("內容") ``` ### 輸入 ```python x = input("提示句") ``` ## Lab 0x00 ```python= """配對註解""" #宣告變數 #印出變數型態 #印出變數內容 #宣告變數 a = input("猜猜我是誰") b = "阿文" print(a) print(type(a)) ``` ## Lab 0x01 ```python= #在colab打出以下程式碼: a = input("猜猜我是誰") print(a) print(type(a)) ``` # 數學運算 - `+` 加, `-` 減, `*` 乘, `/` 除, `%` 取餘數 - `**`次方 # 邏輯運算 - `==` 相等, `!=` 不相等 (數值上) - `True` 真, `False` 假 (開頭要**大寫**) - `in` 屬於, `not in` 不屬於 - `is`, `is not`:記憶體位址是否相同 - `and`, `or`:和、或 ( &&、|| ) - `not`真假互換 ( ! ) # 條件判斷
×
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