CS101 Control Flow
Learn how to control the flow of code execution in Python.
StartKey Concepts
Review core concepts you need to learn to master this subject
Conditional Control
Control Flow
elif
Statement
Handling Exceptions in Python
or
Operator
Equal Operator ==
Not Equals Operator !=
Comparison Operators
Conditional Control
Conditional Control
Conditional statements or conditional control structures allow a program to have different behaviors depending on certain conditions being met.
Intuitively, this mimics the way humans make simple decisions and act upon them. For example, reasoning about whether to go outside might look like:
- Condition: Is it raining outside?
- If it is raining outside, then bring an umbrella.
- Otherwise, do not bring an umbrella.
We could keep adding clauses to make our reasoning more sophisticated, such as “If it is sunny, then wear sunscreen”.
Control Flow
Lesson 1 of 2