# Coding: True and False

Coding in its simplest form can be broken down into 1’s and 0’s. A 1 means it is TRUE and a 0 means it is FALSE. One thing to always keep in mind is that if something is not true then it is false. This system is called Boolean algebra.

When coding it is important to remember that computers have no intuition, so you must state everything and be very specific.

Below is some statements of true and false. It is similar to basic algebra where is you multiply a negative with a negative you get a positive and if you multiply a negative with a positive you get a negative. We are using “!” as the meaning NOT. So if…

• (!(True)) = False –> Not true (-) x True (+) = –
• (!(False)) = True –> Not true (-) x False (-) = +

*When working with loops it must always be true to work.

Truth Tables show the outcomes when you combine 2 different coding expressions using “and”, “or”, and “and or”. For example, if the first statement is true OR the second statement is false than the overall statement is true. If the first statement is true AND the second statement is false than the statement must be false, this is because the statement cannot be true if one is true and the other is false. If the first statement is true AND OR the second statement is false than the statement is true. The “and or” table combines the “or” and the “and” so all possibilities are true and will run with the only exception of if both are false.

“OR” Table

 A Statement B Statement True TRUE FALSE YES TRUE TRUE NO FALSE TRUE YES FALSE FALSE NO

“And” Table

 A Statement B Statement True TRUE FALSE FALSE TRUE TRUE TRUE FALSE TRUE FALSE FALSE FALSE *FALSE

“And” “OR” Table

 A Statement B Statement True TRUE FALSE TRUE TRUE TRUE TRUE FALSE TRUE TRUE FALSE FALSE FALSE

RESOURCES USED