Conditional Control Statements in Python:

 Conditional Control Statements in Python:

Conditional Control statements are used in places where we need to take decisions. The following block will be executed only if the condition is true.

Simple If:

It is the simplest conditional control statement. It’ll evaluate the condition and the result can be true or false.  If the condition is true, the block of statement will be executed and if the condition is false the block of statement will not be executed. Remember that the python uses indentation to identify the block.


Simple If in Python

If else:

In Simple If condition, the statement block executed only when the condition is true. But if you want to execute something else when the condition is false, then you can go for If Else Conditional control statement.


If Else in Python

If Elif Else:

For testing more than one condition If-Elif-Else is used. It begins with If statement then Elif statement and then finally it ends with Else statement. We can write any number of Elif statement.


If-Elif-Else in Python

If-Elif-Else with multiple elif in python


Nested if:

Nested if is using if statement inside another if statement or else statement.



Nested if in Python

Post a Comment