Booleans
In an upcoming discussion on automatic conversion, we will see how values can be interpreted as different types. When converted to BooleansA type of data with two possible values., almost all values are true
, with the following exceptions:
false
"false"
""
0
-0
null
undefined
NaN
Warning to users of Python: notice that the keywords true
and false
are not capitalized.
The function Boolean()
changes the type of a value to a Boolean.
In this example, notice that since the variable mystery
has not been initializedTo give the initial value of a variable or constant., it has the Boolean value false
.
Note:
Hints:
- undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
var mystery;
var numOne = 345.2;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX