In: Math
when i type those python code below, i got True, but when i type not a == e or d and not c > b i still get true, why is that? What will be the returned data type?
a = 1
b = 2
c = 3
d = True
e = 'cool'
a == e or d and c > b
I assume your statement is:
not(a) == e or d and not( c ) > b
And this how the variables are:
a = 1
b = 2
c = 3
d = True
e = 'cool'
Let's start the analysis:
e or d will return 'cool' , this is how python works with or statements. Only an empty string like f = " " will return false. Here,
as e = 'cool', and d = True, we get e or d as True or 'cool'. 'cool' in itself represents true. You can check this by using not(e) in the shell.
For the second part of not(c) > b:
not(b) gives False. In python, only 0 (zero) gives false when using logical operator and False > b ( = 2) implies 0 greater than 2. This is False. Therefore, not(c) > b is False.
Therefore,
e or d and not( c ) > b is equivalent to True and False. This gives False as we are using and operator. You can check this if you run .... True and False .... in command line.
Therefore, you get a == False.
When you apply not to then, you get True.
Therefore, the returned data type is also Boolean.
Hope it helps. Let me know if you need further clarifications.