Operators perform actions on values. Here are some of them:a + b means 'a plus b'.a - b means 'a minus b'.a * b means 'a times b'.a / b means 'a divided by b'.a ^ b means 'a to the power of b'.a = b means 'assign the current value of b to the variable a'.a % b means 'the remainder of a divided by b'.Increasing or decreasing the value of an existing variable is simple. Assign the variable to itself, plus or minus something else. a = 500 a = a + 100 //a is now 600. a = a - 250 //a is now 350. b = "Hey " b = b + " you" //b is now "Hey you"There are various shorthand operators for doing this: a += b means a = a + b .a -= b means a = a - b .a *= b means a = a * b .a /= b means a = a / b .a ^= b means a = a ^ b .a %= b means a = a % b .++ increases a variable by 1, and -- decreases a variable by 1. Make sure you put these operators after the variable. num = 60 num++ //num is now 61. num-- //num is now 60.'true' and 'false' are two truth values that can be used in Mint. Their purpose will become more clear when we get into control flow. a == b checks if a is equal to b. The reason == is used instead of = is because = is already used for variable assignment.a != b checks if a is not equal to b.a > b checks if a is greater than b.a < b checks if a is less than b.a >= b checks if a is greater than or equal to b.a <= b checks if a is less than or equal to b.a in b checks if b contains a.Here are some examples: a = 15 print a == 15 //prints true print a > 0 //prints true print a < 2 //prints false b = 30 print a > b //prints false print a >= b - 15 //prints true c = "hello" print "ello" in "hello" //prints true print "z" in "hello" //prints falseThere are also operators that work on truth values: a and b checks if a and b are both true.a or b checks if a or b are true.a xor b checks if either a is true or b is true, but not both of them.not a returns false if a is true, and true if a is false.a = 2000 b = 2100 print a == 2000 and b > 1000 //true print a != 2000 or b == 2100 //true print a != 2000 and b == 2100 //false print a > 1000 xor b < 1000 //true print not (a == 2000) //falseThere is one type of operator that is a little different than the rest: the empty operator. The empty operator has no symbol. It is a blank operator that is 0 characters in length. The empty operator is used for implicit multiplication. myNumber = 1 + 5(8(6) + 9(10.2)) // Implicitly multiply 8 by 6, 9 by 10.2, and 5 by (8*6 + 9*10.2) otherNumber = 1 2 3 4 // Calculates the factorial of 4. print myNumber print otherNumberIf you run the above program, you should see that otherNumber is 24, which is 1 * 2 * 3 * 4, and myNumber is 700.0, both of which are correct results. Implicit multiplication is often taught in mathematics classes. However, very few programming languages have it as a feature. Previous Lesson: First Program Next Lesson: Basic Control Flow Table of Contents |