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 StatementB StatementTrue
TRUEFALSEYES
TRUETRUENO
FALSETRUEYES
FALSEFALSENO

“And” Table

A StatementB StatementTrue
TRUEFALSEFALSE
TRUETRUETRUE
FALSETRUEFALSE
FALSEFALSE*FALSE

“And” “OR” Table

A StatementB StatementTrue
TRUEFALSETRUE
TRUETRUETRUE
FALSETRUETRUE
FALSEFALSEFALSE

RESOURCES USED

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s