Skip to content

Operators Examples

Operators

  • Arithmetic Operators: (+, -, , /, //, %, *)
  • Assignment Operators: (=, +=, -=, =, /=, //=, *=, \=, ^=, >>=, <<=)
  • Comparison Operators: (==, !=, >, >=, <, <=)
  • Logical Operators: (and, or, not)
  • Membership Operators: (in, not in)
  • Identity Operators: (is, is not)
  • Bitwise Operators: (&, |, ^, ~, <<, >>)

Arithmetic Interesting Operators

Exponentiation Operator

When x = 2 and y = 5:
Exponentiation: x ** y is 2 to the power of 5, aka 2^5 = 32


Floor Division Operator

When fruits = 10 and people = 3:
We need to share the fruits.

Floor Division:
Maximum fruits that can be shared per person: fruits // share_people = 3