Python Conditions
In Python we can use the if
statement to conditionally execute code. For example, if we ask the user to enter his age, we can make different things happen depending on which age the user, such as printing You're young.
or You're old.
depending on if the age is lower than 30 or not. In this lecture we take a closer look at how to achieve this.
Lecture material
Recommended reading
- The following chapters in the book How to Think Like a Computer Scientist: Interactive Edition: