An if statement allows you to execute a block of code if a condition is true. Otherwise, it can run an alternative block of code in its else clause.
The else clause of an if statement is optional.
You can chain multiple if statements that check for multiple conditions one after the other and execute a different block of code when the various conditions are true.
The basic syntax of an if statement is shown here:
if condition: # Run this code if the condition evaluates to True else: # Run this code if the condition evaluates to False
As you can see, the if statement allows you to branch the execution of code based on a condition. If the condition evaluates to true, we execute the code in the if block. If the condition evaluates to false, we execute the code in the else block.