LimioLearn in Flow
🏆 Đấu trường
Đăng nhậpĐăng ký
← Programming for Data Science

Bạn đang xem thử công khai

Đăng nhập để lưu tiến độ, làm bài tập, thảo luận và nhận phản hồi.

Đăng nhập
Module 1: Fundamentals of Python Programming

1.7 Branching with if / elif / else

In / Lưu PDF

1.7 Branching with if / elif / else

After this unit you will: write chains of conditions and correctly predict which branch will run.

Key points

  • Python checks from top to bottom and runs the first branch whose condition is true; the remaining branches are skipped.
  • else belongs to the nearest if at the same indentation level.
  • pass is a placeholder statement that avoids a syntax error when a block has not been written yet.