Tuesday 6 November 2012

Logical Operators

Logical operators are those which help for putting limits in conditions.
Such that if you want to put a limit in if statement of 1 to 20 and 20 to 30. There we will use logical operators. There are Three types of Logical Operators:


  1. And Operator.
  2. Or Operator.
  3. Not Operator.

Syntax of AND Operator:

                          AND operator works when both the given conditions are true and this will give the true. syntax is given:
                                if Firstcondition and Secondcondition:
Here the and is working as and operator.

Syntax of OR Operator:

                         OR operator works if one condition is true from given conditions and this gives a true. Syntax is given:
                             if Firstconditon or secondcondition:
Here the or  working as or operator.

Syntax of NOT Operator:

                        NOT operator only swap the condition, Mean if the condition is true it will make it false and if false then it will make it true.And not operator comes before condition. Syntax is given as
                              if not condition:
Here not is working as NOT operator.

No comments:

Post a Comment