Python - if else Statemment
if else statement is another form of an if statement. The else statement is an optional one and must follow the if conditional statement. There are two possibilities in which one possibility will be executed based on the condition check.
Flow Chart
Syntax of Python if... else
Following is the basic syntax of the if...else decission control flow statement.
if(expression):
statement_1
else:
statement_2
Example with if...else in Python
Below is an example proram to check the given number is even or odd.
A = int(input('enter the value to check: '))
if((A%2)==0):
print('The value A is Even')
else:
print('The value A is Odd')
While executing above program you will get the following output.
F:\>python even.py
enter the value to check: 45
The value A is Odd
For another input:
F:\>python even.py
enter the value to check: 70
The value A is Even