Table of Contents

, , , , , , , , ,

About the Club

Python Club Topics - Operators

Operators

  1. Operators perform operators on variables

Addition Operator

  1. Add numbers, strings, or list items together
    a = ["apple"]
    b = ["banana"]
    print (a+b)

List of operators

  1. Addition ( eg. + )
  2. Subtraction ( eg. - )
  3. Multiplication ( eg. * )
  4. Modulus ( eg. % )

Assignment operators

  1. The following are the same expression
    x = 9
    x += 3
    x = x + 3
    print(x)
  2. The following are the same expression
    x = 33
    x -= 3
    x = x - 3
    print(x)

Comparison operators

  1. Equal to ( eg. == )
    x = 3
    y = 5
    print(x == y)
  2. Grater than or equal to ( eg. >= )
    x = 3
    y = 5
    print(x >= y)
  3. Less than or equal to ( eg. ⇐ )
    x = 3
    y = 5
    print(x <= y)