Boolean Expressions

Cai Gengyang gengyangcai at gmail.com
Tue Sep 26 17:43:31 EDT 2017


Help check if my logic is correct in all 5 expressions


A) Set bool_one equal to the result of 
False and False 

Entire Expression : False and False gives True because both are False 

B) Set bool_two equal to the result of 
-(-(-(-2))) == -2 and 4 >= 16 ** 0.5

-(-(-(-2))) is equal to 2, and 2 is not equal to -2, hence the first term       -(-(-(-2))) == -2 is False. 4 >= 16 ** 0.5 is True because 16 ** 0.5 is equal to 4, and 4 is greater then or equal to 4, hence the 2nd term 4 >= 16 ** 0.5 is True.

Entire expression : False because False and True gives False 

C) Set bool_three equal to the result of 
19 % 4 != 300 / 10 / 10 and False

19 % 4 = 3 which is equal to 300 / 10 / 10 = 3, hence the first term is False. Entire expression is then equal to True, because False and False = True

D) Set bool_four equal to the result of 
-(1 ** 2) < 2 ** 0 and 10 % 10 <= 20 - 10 * 2

-(1 ** 2) is equal to -1 , which is less than 2 ** 0 = 1, hence the first term is True. 2nd term 10 % 10 is equal to 0 , which is less than or equal to 20 - 10 * 2 , hence 2nd term is True.

Entire expression : True and True = True

E) Set bool_five equal to the result of 
True and True

Entire Expression : True and True = True



More information about the Python-list mailing list