--- title: 程式語言基礎(二) tags: python, hackmd date: 2023-09-26 langs: zh slideOptions: theme: moon transition: slide spotlight: enabled: true slideNumber: night type: slide --- ### GDSC NYUST x 資訊創客社 <br> ### Topic 1:基礎工具與程式語言入門 #### Class 2:程式語言基礎(二) <br> #### 2023/10/03 (Tue) 19:30 - 20:30 #### 講師:GDSC課程組 <img src="https://hackmd.io/_uploads/ryyGo9pka.png" height="200px">![]() --- Part 1 常見Functions ---- len() :計算長度或元素的數量  ---- str()、int()、float() :類型轉換  ---- max()和min: 最大值與最小值  ---- abs():返回絕對值  ---- round():用於四捨五入浮點數  --- Part 2 自定義Function ---- 1. 什麼是function? ---- 2. 創建function  ---- 3. function 呼叫  ---- 4. function 返回值  ---- 5. 默認參數  --- Part 3 while loop ---- 什麼是while?  <span style="font-size:24px"> 執行不斷重複執行的任務,直到某個條件滿足 </span> ---- <p class="text-center">防止無限迴圈</p> | <p class="text-center">正確</p> | <p class="text-center">錯誤</p> | | -------- | -------- | | |  | ---- 使用break和continue  --- Part 4 For Loops ---- for 變數 in 序列  ---- 使用range 函數  ---- 範例:印出偶數  ---- 使用break and continue  ---- 進階 列表推導(List Comprehensions):  <span style="font-size:24px">💡Tips: 列表推導的語法:[expr for var in iterable] expr是任意合法的表達式;var是變數名;itervable是可迭代的Python物件 </span> --- Part 5 Try Except ---- 1. 怎樣會導致異常?  ---- 2. 使用 try 和 except:  ---- 3. 處理不同種類的異常:  ---- 4. 使用通用的 except:  ---- 5. 使用 else 和 finally:  ---- 6. 自定義異常:  --- Q & A 時間
×
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