Back to Kids Home
๐Ÿ”ง Lesson 4

Operators: Math Superpowers! โž•โž–โœ–๏ธโž—

Operators are special symbols that do things like math and comparisons. They're like tools in a toolbox!

๐Ÿงฎ Math Operators

You already know these from math class! Computers use the same symbols (mostly).

+

Addition

Add things together

5 + 3 = 8
-

Subtraction

Take things away

10 - 4 = 6
*

Multiplication

We use * instead of ร—

6 * 7 = 42
/

Division

We use / instead of รท

20 / 4 = 5

๐ŸŽฎ Math in Video Games!

Games use math operators ALL the time. Here's what happens behind the scenes:

๐Ÿ’ฐ

You collect 10 coins!

coins = coins + 10
๐Ÿ’”

You get hit! Lose 25 health!

health = health - 25
โš”๏ธ

Double damage power-up!

damage = damage * 2
๐Ÿ‘ฅ

Split loot between 4 players!

share = treasure / 4

โš–๏ธ Comparison Operators

These help the computer compare things and answer questions! The answer is always true or false.

===

Equals (Is the same as?)

5 === 5 is true โœ…

5 === 3 is false โŒ

!==

Not Equals (Is different?)

5 !== 3 is true โœ…

5 !== 5 is false โŒ

>

Greater Than

10 > 5 is true โœ…

<

Less Than

3 < 7 is true โœ…

>=

Greater or Equal

5 >= 5 is true โœ…

<=

Less or Equal

4 <= 6 is true โœ…

๐Ÿ•น๏ธ Games Ask Questions Too!

Games use comparisons to make decisions. Here are some examples:

๐Ÿ’€

Game Over Check

health <= 0

If true, game over!

๐Ÿ†

Level Up Check

points >= 1000

If true, level up!

๐Ÿ”‘

Door Check

keys > 0

If true, can open door!

๐ŸŽ

Shop Check

coins >= price

If true, can buy item!

๐Ÿง  Quiz Time!

What do these equal? True or False?

10 > 5

Answer: true โœ…

3 === 3

Answer: true โœ…

7 < 2

Answer: false โŒ

100 !== 50

Answer: true โœ…

โญ Remember This!

  • 1

    Math operators do calculations: + - * /

  • 2

    We use * for multiply and / for divide

  • 3

    Comparison operators ask questions: === !== > < >= <=

  • 4

    Comparisons always answer true or false