Conditional Statements

Else If Statements

Else if statements are used as a fall back for if statements. When an if statements is false the else if statements are now evaluated for whether or not they are true.

We initiate the value of x to “2**2”, which is equal to 4. Since the comparison “x > 4” evaluates to false(because 4 > 4 is not true), the if statement passes on to the following else if statement.

Since “4 % 2 == 0” evaluates to true, the code block of the else if is executed.