A program sometimes may have to make choices. These choices can execute different code depending on certain condition. In Python the if statement is used for conditional execution.
The if statement may be combined with certain operator such as equality (==), greater than (>=), smaller than (<=) and not equal (!=). Conditions may be combined using the keywords or and and.
Related course: Python Crash Course: Master Python Programming!
In the example below we show the use of if-statements.
Copy the program below and run it.
Do these exercises:
1\. Make a program that asks the number between 1 and 10\.
Once completed continue with the next exercise.