• Relational or Comparison Operators
  • Python: Learn the Basics fast from Python Programming Experts




    Download 337.24 Kb.
    Pdf ko'rish
    bet7/10
    Sana12.05.2023
    Hajmi337.24 Kb.
    #58921
    1   2   3   4   5   6   7   8   9   10
    Bog'liq
    Patterson C. - Python Learn the Basics FAST From Python Programming Experts
    10 nazorat, Axrorova K. F8, majburiy matematika 24, Prosentga oid masalalar
    Membership Operators
    These operators are used in the Python language to check for “membership” in a code
    sequence (e.g. lists, tuples, strings, etc.) Currently, Python only supports 2 membership
    operators. These are:
    Operators
    Definition
    Examples
    Is
    This is evaluated as true if the operands on either side of the
    operator are pointing to a single element.
    X is Y. “Is” is a result of (1 if id (X) is
    equal to id (Y))
    Is not
    This is evaluated as false if the operands on either side of the
    operator are pointing to a single element.
    X is not Y. “Is not” is a result of (1 if id
    (X) is not equal to id (Y))
    Relational or Comparison Operators


    These operators are used to compare the values of the operands and determine the relation
    present among them. Let us assume that variable X is equal to 1 and that variable Y is
    equal to 2.
    Operators
    Definition
    Examples
    <=
    The condition is only true if the left operand’s value is less than or
    equivalent to the right operand’s value.
    (X <= Y) is true.
    >=
    The condition is only true if the left operand’s value is great than or equal
    to the right operand’s value.
    (Y >= X) is true.
    <>
    The condition is only true if the values of the two operands are unequal.
    (X <> Y) is true.
    <
    The condition is only true if the value of the right operand is greater than
    the value of the left operand.
    (X < Y) is true.
    >
    The condition is only true if the value of the right operand is lesser than the
    value of the left operand.
    (X > Y) is not true.
    ==
    The condition is only true if the values of the operands are equal.
    (X == Y) is not true.
    !=
    The condition is only true if the values of the operands are not equal.
    This one is similar to <> above.

    Download 337.24 Kb.
    1   2   3   4   5   6   7   8   9   10




    Download 337.24 Kb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Python: Learn the Basics fast from Python Programming Experts

    Download 337.24 Kb.
    Pdf ko'rish