Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 19 Online
OpenStudy (anonymous):

is "True or True and False" the same as "(True or True) and False" which is False or "True or (True and False)" which is True? here, the quotes i type mean general code

OpenStudy (anonymous):

You could type it into the Python shell and it would tell you ... But by order of operations AND is processed before OR without brackets. See this link http://www.informit.com/articles/article.aspx?p=459269&seqNum=11

OpenStudy (anonymous):

Without parentheses to clarify, this would evaluate as "True or (True and False)" = True. "and" evaluating first... (as far as I know in C, C++, C#, JS and Java)

OpenStudy (konradzuse):

I don't think it checks && or || first, I believe it goes based on what is read first. Make a Truth Table and see how it goes.

OpenStudy (anonymous):

Idle output below, as you can see in both cases with "and" before "or" or "and" after "or" it is equivalent to putting brackets around the "and" part meaning it is processed first. >>> True or True and False True >>> True or (True and False) True >>> (True or True) and False False >>> False and False or True True >>> (False and False) or True True >>> False and (False or True) False

OpenStudy (konradzuse):

The thingj is, he said he's using "General code." I think this is more of an example of Digital Electronics. ANDS, NOTS, ORS, NORS, XOR, etc. The thing is what are the variables? What is true, and what is false? 1 variable? 2?

OpenStudy (anonymous):

without parentheses, the precedence can be judged with 'NAO' (not , and , or)

OpenStudy (anonymous):

in any programming language there is precedence of operators (which one must be evaluated at first) , so just check the precedence and you'll get your answer :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!