4.1 Decision Making
Decision making in programming allows the program to choose different actions based on conditions. This is similar to how we make decisions in real life. For example, deciding whether to take an umbrella based on the weather situation. Python provide variety of conditional statements to implement decision making.
4.1.1 if Statement
The if statement lets us make decisions based on conditions. If the condition is true, it runs a block of code. In Python indentation defines the structure block or scope of your code. In Python proper indentation is mandatory. Incorrect indentation may cause error in your code (Indentation Error).
# Syntax of if statement if condition: If condition: code to run if the condition is true