DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
>>> 0xbadbeef
195935983

You can also convert back and forth by using the base
keyword in front of the value you want to exchange, as in
these examples:


>>> hex(195935983)
'0xbadbeef'

>>> bin(195935983)
'0b1011101011011011111011101111'

Booleans


A Boolean has only two possible values, True and False.
You use comparison operators to evaluate between two
Boolean objects in Python. This data type is the
foundation for constructing conditional steps and
decisions within programs. Table 3-4 shows the various
Boolean comparison operators and some examples of
how to use them.


Table 3-4 Boolean Comparisons

OperatorWhat It DoesExampleEvaluates to

< Less than 5 < 10 True

> Greater than 6.5 > 3.5 True

<= Less than or equal to 0 <= -5 False

>= Greater than or equal to 6 >= 6 True

== Equal to 5 = “5” False
Free download pdf