i can reduce  the definition of  Boolean   in Python to Logic  expressions of Combinations.   the Logic  the  base  in the most t of programming languages
Boolean values are the two constant objects False and True.
Lets   give some examples  based  on  2.7 from Linux mint  and  Centos 7 :

Boolean values

a = 10
b = 11
print 1, a == 10
print 2, a == 11
print 3, a == 10 and b == 11
print 4, a == 11 and b == 11
print 5, not a == 11 and b == 11
print 8, not (a == 11 and b == 10)
print 9, not a == 11 and b == 10
print 10, a == 11 or b == 11
print 11, a == 11 or b == 10

 

The output of this  python script  will be

1 True
2 False
3 True
4 False
5 True
10 True
11 False
8 True
9 False
10 True
11 False

Lets  test   the  script locally

screenshot-from-2016-09-22-19-52-13

This is how  you can solve the Puzel :

Testing   Some Boolean Strings

To see what the return value Lets run the Code 2016-09-23_100203

Good  Boolean Example :

 

name = raw_input(“What is your name? “)
password = raw_input(“What is your the password? “)
if name == “mohamed” and password == “Jointux”:
print “Welcome Mohamed”
elif name == “mel” and password == “Join”:
print “Welcome Mel”
else:
print “you are a hacker. i dont know you. your  IP will be banned in 3 seconds ”

2016-09-23_102019

with wrong answer you get this answer
2016-09-23_102146

these  are  different examples that  can you exercise  on your local  computer . but  for  sure  you can find more examples and maybe more  complicated  cases ,   please  back to us  if  you encounter  any issues .

 

Spread the love

LEAVE A REPLY

Please enter your comment!
Please enter your name here