General Notes

Operators

  • An operator is a symbol or keyword in programming that tells the computer to perform a specific operation on one or more values (called operands)
  • May be used to compare types REAL/FLOAT and INTEGER
  • May be used to compare types CHAR and STRING
  • Case sensitive when used to compare types CHAR and/or STRING
  • Cannot be used to compare two records or object

Arithmetic operators

OperatorNameDescriptionPython
+AdditionAdds together two valuesa + b
-SubtractionSubtracts one value from anothera - b
*MultiplicationMultiplies two valuesa * b
/DivisionDivides one value by anothera / y
%ModulusReturns the division remaindera % y
**ExponentReturns a to the power of ba ** b
//Floor DivideDivide & return the whole numbera // b

Assignment operators

OperatorExample
=a = 5
<operator>=a += 5 (Represents a = a + 5)

Comparison operators

Returns a boolean value

PythonDescription
var == varEqual to
var != varNot Equal
<, >, <=, >=Greater/Less than (or equal to)

Logical operators

Works similar to logic gates

OperatorNameExample
andLogical anda > 9 and a < 25
orLogical ora > 9 or a < 25
notLogical Notnot (a == 25)

Precedence

Sets the rule on the order of operators

OperatorName
()Parentheses
**Exponent
* / // % Multiplication, Division, Floor Division, Modulus
+ -Addition, Subtraction
== != > < <= >=Comparison Operators
notLogical NOT
andLogical AND
orLogical OR