Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Python 程式設計#3 | 結構與流程控制
33 students

Python 程式設計#3 | 結構與流程控制

Structure and Flow Control | Python Programming
Last updated 10/2025
Chinese (Traditional)
EnglishChinese (Traditional)

What you'll learn

  • 知識與技能:程式語法與結構基礎 (Knowledge and Skill: Programming Syntax and Structural Foundation)
  • 技能:實作流程控制指令 (Skill: Implementing Flow Control Commands)
  • 技能:設計函式與管理變數範圍 (Skill: Designing Functions and Managing Variable Scope)
  • 技能:能控制與中斷重複結構的執行 (Skill: Controlling and Terminating Repetition Structure Execution)

Course content

1 section • 7 lectures • 1h 51m total length
  • Introduction to Statements and Flow Control | 程式語句與流程控制概述9:25
  • Conditional Flow Control (Part 1) | 判斷式流程控制9:08
  • Conditional Flow Control (Part 2) | 判斷式流程控制21:49
  • Loop Flow Control | 迴圈流程控制35:03
  • Introduction to Functions (Part 1) | 函式介紹15:54
  • Introduction to Functions (Part 2) | 函式介紹10:45
  • Variable Scope and Lifecycle | 變數與生命週期9:12

Requirements

  • 具有國中數學之能力 (Proficiency in basic mathematics "junior high school level".)
  • 具有電腦基礎知識及資訊素養 (Basic computer knowledge and information literacy.)

Description

本課程闡述 Python 程式碼的組織方式與執行流程控制。Python 程式語句以換行結束,並強制使用 4 個空白作為程式碼區段的區隔。程式碼流程控制結構分為循序、選擇和重複三大類。

在選擇結構中,主要使用 if、if…else 或 if…elif…else 進行條件判斷,Python 3.10 版本後更提供 match 選擇式。重複結構則由 for 迴圈(用於遍歷資料集合)和 while 迴圈(用於條件判斷式循環)組成,可搭配 break 或 continue 控制循環。

此外,程式功能可透過 功能函式或自訂函式 (def) 管理。函式內的變數屬區域變數,離開區段即結束生命週期。若要在函式內修改外部的全域變數,必須顯式使用 global 關鍵字。


This course details Python code organization and execution flow control. Python statements end with a newline, and code blocks are strictly delimited by 4 spaces. Program flow control structures are categorized into Sequential, Selection, and Repetition.

The Selection structure primarily uses if, if…else, or if…elif…else for conditional judgment, with the match construct available since Python 3.10. The Repetition structure consists of the for loop (for iterating over data collections) and the while loop (for conditional looping), which can be managed using break or continue.

Furthermore, program functionality is managed via built-in functions or custom functions (def). Variables within a function are local variables, whose lifecycle ends upon exiting the block. To modify an external global variable from within a function, the global keyword must be explicitly used.

Who this course is for:

  • 對程式設計感興趣的初級開發者 (For beginner developers interested in programming)