Assignment Operator
Arithmetic Operators
Boolean Operators
Comparisson Operators
Logical Operators
Precedence
=
the equals sign sets a variable equal to a value. float $a = 2.135;
+Exercise: Make 2 polyCubes and name then cube1 and cube2. Create 2 variables to hold the widths. Edit the cubes to set the widths. Create a new cube that is the sum of the two widths (add them). Create another cube that is half of the width of cube1.
Add two elements
$C = $A + $B;-
Subtract two elements
$C = $A - $B;*
Multiply two elements
$C = $A * $B;/
Divide two elements together
$C = $A / $B;%
Find the fractional remainder of the division
$C = $A % $B;
true, yes, on, 1Here are some examples using a boolean
false, no, off, 0
$a = yes;
$b = false;
<The relational operators are typically used in IF blocks and loops.
less than
A < B>
greater than
A > B<=
less than or equal
A <= B>=
greater than or equal
A >= B==
equal to
A == B!=
not equal to
A != B
||In this example we use the not operator.
or
a || b&&
and
a && b!
not
!a
if (2 < 3) || (1 > 3)In this example we use the and operator.
{
print "this is true";
}
else
{
print "this is false";
}
if (2 < 3) && (1 > 3)In this example we use the not operator.
{
print "this is true";
}
else
{
print "this is false";
}
if !(5 < 3)Here are examples using the and plus the or operator:
{
print "this is true";
}
else
{
print "this is false";
}
if(( 2 < 3 && 3 > 1 ) || ( 2>0 && 0>-1 ))In this example we use the not operator.
{
print "this is true";
}
else
{
print "this is false";
}
if(!(5 < 3 && 3 > 1))
{
print "this is False";
}
( ), [ ] !, ++, --
*, /, %, ^
+, -
<, <=, >, >=
==, !=
&&
||
=, +=, -=, *=, /=
$a += 5;is the same as
$a = $a + 5;
$a ++;is the same as
$a = $a + 1;