Skip to Content
Learn
Variables
Arithmetic Operations

Computers are incredible at doing calculations. Now that we have declared variables, letโ€™s use them with arithmetic operators to calculate things!

Emojicode supports arithmetic operators for:

  • โž•: addition
  • โž–: subtraction
  • โœ–๏ธ: multiplication
  • โž—: division
  • ๐Ÿšฎ: modulo (divides and gives the remainder)

For example:

4 โž• 2 โžก๏ธ score1 ๐Ÿ’ญ scores1 is 6 4 โž– 2 โžก๏ธ score2 ๐Ÿ’ญ scores2 is 2 4 โœ–๏ธ 2 โžก๏ธ score3 ๐Ÿ’ญ scores3 is 8 4 โž— 2 โžก๏ธ score4 ๐Ÿ’ญ scores4 is 2 4 ๐Ÿšฎ 2 โžก๏ธ score5 ๐Ÿ’ญ scores5 is 0

Here, we are doing some arithmetic operations and storing the results in five different constants.

Instructions

1.

In the code editor, we have already declared and initialized a variable called amount.

Declare a new variable named tip and give it the value of amount multiplied by 0.2.

Note: There are quite a few variations of xโ€™s in the emoji picker. Make sure to use โœ–๏ธ.

2.

Use string interpolation to print a message that says:

The tip is $[tip]

Where [tip] is the value of the tip constant.

Folder Icon

Take this course for free

Already have an account?