Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (kikuo):

if age is greater than 12 OR age is less than 62 then No matter what value is in age, one condition or the other must be true. That means the whole expression must always be true. This statement likely meant to use AND. I don't understand this

OpenStudy (kikuo):

@Sachintha

OpenStudy (rsmith6559):

You're right.

OpenStudy (kikuo):

@rsmith6559 No, I mean I don't understand what they're saying haha.

geerky42 (geerky42):

Do you know the difference between OR and AND?

OpenStudy (kikuo):

Yes

geerky42 (geerky42):

"age is greater than 12 OR age is less than 62" is always true because one of them must be true, right?

geerky42 (geerky42):

And therefore statement should be using AND to make it more meaningfulness.

geerky42 (geerky42):

Using AND operation, the age MUST be in between 12 and 62 for statement to be true, because if one of them is false, then the whole statement is false. Does that make sense?

OpenStudy (kikuo):

@geerky42 Not quite

OpenStudy (sachintha):

Do you the know what the AND gate does?

OpenStudy (kikuo):

Yes @Sachintha I just don't understand why AND should've been used instead of OR

OpenStudy (sachintha):

Age should be in between 12 and 62 for whole statement to be true. This means that both of the statements should be true because only one variable is considered here. It's useless to use OR for two conditions with the same variable.

geerky42 (geerky42):

In addition, OR is meaningless because then we could just use the Boolean value "True" instead.

OpenStudy (rsmith6559):

And & or are the same in every day use as they are in programming. For instance: youUnderstand = ( ( myExplanationIsGoodEnough == True ) and ( myExampleIsGoodEnough == True ) ) If I'm lucky, instead of both of those being required, either will do the trick, which would be an OR relationship. To break down what's happening, myExplanationIsGoodEnough is evaluated, if compares to True as equal, the inside of that inner parenthesis evaluates to True. The same is done for myExampleIsGoodEnough. The outer parenthesis evaluates the results of the two inner parenthesis, so if both of them are True, the whole thing evaluates to True. To oversimplify: AND == ALL must be True OR == ANY must be True

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!