Data Types (Numbers, String, Boolean)


Numbers

A number can be of any value that is positive, negative or in decimals.

In the example above, we have a positive number, 1, and a positive decimal number, 2.1

In the example above, we have a negative number, -5, and a negative decimal number, -3.9

In the example above, we can perform different action with numbers such as addition, subtraction, division or comparison.

Strings

Strings are pieces of text within the " "

In the example above,

Booleans (True or False)

Booleans are "True" or "False"

In the example above, we declared a variable and assign the boolean value of "True" to 't' and "False" to 'f'

Not Operator

We can convert a boolean from "True" to "False" using the "NOT" operator and vice versa!

And Operator

In the example above, we use the "AND" operator which takes two boolean and return a boolean. AS A RULE OF THUMB, IF ANY OF THE BOOLEAN HAS A "FALSE", THE RESULT WILL AUTOMATICALLY BE "FALSE", THE RESULT WILL ONLY BE "TRUE" WHEN THE TWO BOOLEANS ARE "TRUE".

Or Operator

IN THE EXAMPLE ABOVE, WE USE THE "OR" OPERATOR WHICH TAKES TWO BOOLEAN AND RETURN A BOOLEAN. AS A RULE OF THUMB, IF ANY OF THE BOOLEAN HAS A "TRUE", THE RESULT WILL AUTOMATICALLY BE "TRUE" AS WELL, THE RESULT WILL ONLY BE "FALSE" WHEN BOTH BOOLEANS ARE "FALSE

Conclusion

Download pdf:

Click to Download pdf