Boolean: Difference between revisions
Mr. MacKenty (talk | contribs) No edit summary |
Mr. MacKenty (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 10: | Line 10: | ||
In PHP: | In PHP: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="PHP"> | ||
<?php | <?php | ||
$myFirstVar = True; // assign the value TRUE to $myFirstVar | $myFirstVar = True; // assign the value TRUE to $myFirstVar | ||
Line 19: | Line 19: | ||
In Python: | In Python: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="Python"> | ||
myFirstVar = True | myFirstVar = True | ||
myOtherVar = False | myOtherVar = False | ||
Line 25: | Line 25: | ||
In Javascript: | In Javascript: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="JavaScript"> | ||
var myFirstVar = true; | var myFirstVar = true; | ||
var myOtherVar = false; | var myOtherVar = false; |
Latest revision as of 14:04, 29 June 2019
In most computer programming languages, a Boolean data type is a data type with only two possible values: true or false.[2]
By convention we can express true as the integer 1 and false as the integer 0 (zero). Please be careful as some programming languages treat an empty or unset value as FALSE.
Please know it is very common to use booleans to test for a condition. If something is TRUE then select the true option, if something is FALSE, then select the false option.
Example[edit]
In PHP:
<?php
$myFirstVar = True; // assign the value TRUE to $myFirstVar
$myOtherVar = False; // assign the value FALSE to $myOtherVar
?>
In Python:
myFirstVar = True
myOtherVar = False
In Javascript:
var myFirstVar = true;
var myOtherVar = false;
See Also[edit]
Standards[edit]
- Define the terms: variable, constant, operator, object.