Operators

ASnake Documentation

Table Of Contents

Summary:

Operators in Python are symbols that perform actions on expressions. They can be:

  1. Unary which operates on one operand.
  2. Binary which operates on two operand.
  3. Ternary which operates on three operands. This page has a section which covers ternary.

It is a big topic that is covered better elsewhere. Skip to the ASnake specific section to see the operators it adds. Up until then, Python's operators will be listed with minimal explanation.

Unary Operators:

Operators that operate on one operand.

Binary Operators:

Operators that operate on two operands.

Logical

Operators that perform logical operations.

Linear Operators

Operators that perform arithmetic operations (usually on numerical values, but not always).

Addition aliases:

  1. +
  2. plus

Subtraction aliases:

  1. -
  2. minus

Multiplication aliases:

  1. *
  2. times

Division aliases:

  1. /
  2. divide
  3. divide by

Rounding Division aliases:

  1. //
  2. rdivide
  3. rdivide by
  4. rounddivide
  5. rounddivide by
  6. round divide
  7. round divide by

Modulo aliases:

  1. %
  2. modulo
  3. remainder

Bitwise

Operators that perform bitwise operations.

Examples:

Conditions

Operators used for comparison. Very useful for conditionals.

Equals aliases:

  1. ==
  2. = (context dependent)
  3. is (context dependent)
  4. equal
  5. equals

Not Equals aliases:

  1. !=
  2. isnt
  3. isn't
  4. not equal
  5. unequal

Less Than aliases:

  1. <
  2. less
  3. less than
  4. is less
  5. is less than
  6. lesser
  7. lesser than

Less Than Or Equal To aliases:

  1. <=
  2. =<

Greater Than aliases:

  1. >
  2. greater
  3. greater than
  4. is greater
  5. is greater than

Greater Than Or Equal To aliases:

  1. >=
  2. =>

ASnake's Operators:

Unary Increment/Decrement

Increments and decrements are covered on this page.

Binary Divmod

/// is a shortcut for the builtin Python function divmod. It returns a tuple with the 0th element being the divide result, and the 1st element being the remainder result. You can use a index to access a specific value.

Example:

12 /// 2
# compiles to: divmod(12, 3)
# result: (6, 0)

12 /// 2 [0]
# result: 6
Try this code ➤

Tenary Operators:

There is only one, covered on the conditionals page.

Scroll to top