Conditional Statements in Python

we are mainly uses 4 types of Conditional Statements in Python. they are  If Statement,If Else,While Loop,For Loop.

If Conditional Statement

when the condition is satisfied, the statements in the if block are executed, otherwise not.

Syntax :if :   statements

Example for Python If Conditional Statement

Output :

If Else Conditional Statement

when the condition is satisfied, the statements in the if block are executed, and when the condition is not satisfied, the statements in the else block are executed.

Syntax : if :  statementselse:  statements

Output :

While Loop Conditional Statement

When condition is true, the set of statements are executed, and when the condition is false, the loop is broken and the program control continues with the rest of the statements in program.

Syntax : while(expression):  set-of-statements  set-of-statementsrest-of-the-program

Example for While Loop in Python