Python Decision Making

In this tutorial you will learn about the Python Decision Making and its application with practical example.

In Python, decision-making statements allow you to make a decision, based upon the result of a test condition. The decision-making statements are also referred to as Conditional Statements. Decision Making Statement enable computer to decide which block of code to be execute based on some conditional choices. In Python, if statement, if else statements, elif statements, nested if conditions and single statement conditions used as decision-making statements.

Decision Making Statements In Python

In python, we have a rich set of Decision Making statements that enable computers to decide which block of code to be executed based on some conditional choices. Decision making statement evaluates single or multiple test expressions which results “TRUE” or “FALSE”. The outcome of the test condition helps to determine which block of statement(s) to executed if the condition is “TRUE” or “FALSE” otherwise.

Types of Decision-Making Statements

In Python, we have following types of decision making statements :

  • if statement
  • if-else statement
  • if-elif-else ladder statement
  • nested if statements

Python if statement

Block of statement executed only when specified test expression is true.

Python if-else statement

When we want to execute some block of code if a condition is true and another block of code if a condition is false, In such a case we use if….else statement.

Python if-elif-else ladder

Python Nested if Statements

When there is an if statement inside another if statement then it is known as nested if else.

 

tyu

In this tutorial we have learn about the Python Decision Making and its application with practical example. I hope you will like this tutorial.