Skip to content
BENIBIX Learn

Operator

Development🧩 Programming ConceptsData and Variables

A sign like +, > or and that works on values and gives a result.

Think of it like

Think of it like the plus and minus keys. Each key does one job.

Example

In price * 2 > 50, the * runs first, then > checks the answer. A price of 30 gives True.

Why it matters

Almost every line of code uses an operator. Knowing which goes first stops quiet maths bugs.

Definition

An operator is a sign that does something with values. + adds, > compares and and joins two tests together. The values it works on are called operands, so in 3 + 4 the operands are 3 and 4. Operators come in families: maths, comparing and logic. When a line has several, some go first, the way times goes before plus.

Example code

python
>>> 3 + 4 * 2
11
>>> (3 + 4) * 2
14
Times goes first, unless brackets say what goes first.

Common mistake

Forgetting the order rules. When in doubt, add brackets so the order is plain to see.

Key takeaways

  1. 1
    Works on values. It takes one or two values in.
  2. 2
    Gives a result. A number, a true or a false.
  3. 3
    Has an order. Some operators run before others.

Learn it properly