In Python, decision statements are used to control the flow of execution based on certain conditions. The two main decision statements in Python are “if” statements and “if-else” statements. There is also an extended version called the “if-elif-else” statement, which allows for multiple conditions to be evaluated.

  1. If statement: The simplest form of a decision statement is the “if” statement. It executes a block of code only if a certain condition is true.
python
if condition: # code to execute if the condition is true

Example:

python
x = 10 if x > 5: print("x is greater than 5")
  1. If-else statement: The “if-else” statement provides an alternative block of code to be executed if the condition in the “if” statement is false.
python
if condition: # code to execute if the condition is true else: # code to execute if the condition is false

Example:

python
x = 3 if x > 5: print("x is greater than 5") else: print("x is not greater than 5")
  1. If-elif-else statement: The “if-elif-else” statement allows for multiple conditions to be evaluated. The code block associated with the first condition that is true will be executed.
python
if condition1: # code to execute if condition1 is true elif condition2: # code to execute if condition2 is true else: # code to execute if all conditions are false

Example:

python
x = 10 if x > 15: print("x is greater than 15") elif x > 5: print("x is greater than 5 but not greater than 15") else: print("x is not greater than 5")

These are the basic decision statements in Python. They allow you to control the flow of your program based on certain conditions and make it more dynamic and responsive.