Python‎ > ‎

Boolean

http://www.adilwaseem.com/



Definition
Bealoon is comparison of the values among equation home result is always True or false. Boolean operations are built-in-functions in the Python. There are being used for testing the veracity of information and comparison in string , numeric or any other comparable values.

< Greater than right hand side value
<= Greater or equal to left hand side value
> Less than right side value
>= Equal or greater than right side value
== Equal
!= Not equal

Examples
Sum of variable are returned false.
 >>> 
>>> x=34
>>> y=38
>>> z=43
>>> x+y >= z+y
False
>>> 

equal(== )
The python tested the values through input() function and tested whether the string values are equal.
>>> x=input("Please enter your name: ")
Please enter your name: Adil
>>> x=="Waseem"
False

not equal(!=)
Python tested that list values are not equal.
 >>> 
>>> x=[1,2,3,4,5]
>>> y=[1,2,3,4,5,6]
>>> y>=x
True
>>> x==y
False
>>> x !=y
True

Similarly, Python tested x value is equal or greater than y+z in lists 
 >>> 
>>> x=[1,2,3,4,5]
>>> y=[1,2,3]
>>> z=[4,5]
>>> x > y+z
False
>>> x >= y+z
True
>>>

The method returns False in the string whether the x contains digit through.
 >>> import string
>>> string.hexdigits
'0123456789abcdefABCDEF'
>>> x=string.hexdigits
>>> x
'0123456789abcdefABCDEF'
>>> x.isdigit()
False


Comments