filmov
tv
The Python “if-elif-else” block | Conditional execution under multiple conditions
Показать описание
LINKS TO FULL CONTENT
FULL LESSON DESCRIPTION
So far, all of our Python programs have executed statements sequentially. In a program that has 3 lines of code, we expect line 1 to run first, then line 2, then line 3. While this execution model has already allowed us to introduce some level of interaction with the user, the real power of a programming language comes when you can alter the sequential control flow of your program by deciding what lines of code to execute, not to execute, or to execute multiple times based on certain conditions. In this lesson we introduce conditional execution as the most basic form of non-sequential control flow in Python.
FULL LESSON CONTENT
Part 1. The ‘if’ block
Part 2. The ‘if-else’ block
Part 3. The ‘if-elif-else’ block
FULL LESSON DESCRIPTION
So far, all of our Python programs have executed statements sequentially. In a program that has 3 lines of code, we expect line 1 to run first, then line 2, then line 3. While this execution model has already allowed us to introduce some level of interaction with the user, the real power of a programming language comes when you can alter the sequential control flow of your program by deciding what lines of code to execute, not to execute, or to execute multiple times based on certain conditions. In this lesson we introduce conditional execution as the most basic form of non-sequential control flow in Python.
FULL LESSON CONTENT
Part 1. The ‘if’ block
Part 2. The ‘if-else’ block
Part 3. The ‘if-elif-else’ block