Session -3 (Decision Making)

In this session , I’ll cover below topics following by some assessments

  1. Decision Making
  2. IF Statement
  3. IF…Else Statement
  4. Comparison Operators
  5. Logical Operators

1.Decision Making

Decision making is anticipation of conditions occurring while execution of the program and specifying actions taken according to the conditions.

Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. You need to determine which action to take and which statements to execute if outcome is TRUE or FALSE otherwise.

  • Conditional execution
  • Conditional expression
  • Outcomes TRUE →1 or FALSE →0
  • Outcome as 1 then Action_1
  • Outcome as 0 then Action_2 or No_Action

2.IF Statement

if statement contains particular condition if the condition will be true, then statements which are written under if statement will execute.

Example :

Input ,

Output ,

3. IF …Else Statement

if the condition of “if statement” will be true, then all the statements which are written under if statement will execute, otherwise else part always execute.

Example :

Input ,

Output ,

4.Compassion Operators

  • = = : Equal to
  • ! = : Not equal to
  • > : Greater than and > = : Greater than or equal to
  • < : Less than and < = : Less than or equal to

A comparison operator in python, also called python relational operator, compares the values of two operands and returns True or False based on whether the condition is met. We have six of these, including and limited to- less than, greater than, less than or equal to, greater than or equal to, equal to, and not equal to. So, let’s begin with the Python Comparison operators.

4.Logical Operators

  • and : AND
  • or : OR
  • not : NOT
OperatorDescriptionExample
and Logical ANDIf both the operands are true then condition becomes true.(a and b) is true.
or Logical ORIf any of the two operands are non-zero then condition becomes true.(a or b) is true.
not Logical NOTUsed to reverse the logical state of its operand.Not(a and b) is false

Leave a comment