### Truth Tables Confuse Me

I've been learning python and using the learn python the hard way site, but got to exercise 27 and everything became confusing ( http://learnpythonthehardway.org/book/ex27.html ). The easiest one is the first table, not True is False and not False is True outside of that I have forgotten all the Truth Tables things I've learned in college. Think I even had trouble with them in college, now that I think about it. Like I don't understand the OR AND parts for how you get T or T is T, T or F is T, F or T is T, F or F is F.... Is there a site that explains this in laymen terms? Google just keeps sending me to college sites that don't really explain it outside of displaying the tables that page does.
Think of it like this.

If it walks like a duck, and talks like a duck, it's a duck.

Rebecca walks like a duck, and does not talk like a duck. So, she is not a duck. Because we have said walk and talk, both conditions must be true for the conclusion to be true. But we have one false and one true, so the conclusion is false, she is not a duck.

In other words, (x and y) is true only if x and y are both true (true and true).

If Timmy is at least 10, or taller than 5', then he may ride the roller coaster.

(x or y)

Timmy is 10 years old, but he is not taller than 5' (true or false). He gets to ride the roller coaster because the rule states he must meet only one of the two requirements.

 ``123`` ``````if (Timmy.getHeight >= 5 || Timmy.getAge() >= 10) { Timmy.rideRollerCoaster(); }``````

not (true or false).

 ``123`` ``````If (! (Timmy.getHeight >= 5 || Timmy.getAge() >= 10)) { Timmy.wishBegToRideCoaster("please"); }``````

 ``` not (true or false) =(not true) and (not false)```

If Timmy is not (5' or 10 yo), then he is not 5' and not 10 yo.

If Timmy is both 5' and 10 yo, x == true, and y == true, (x or y) -> (true or true) == true;

Last edited on
Truth tables are a formal definition of Boolean operators. Asking why T OR T = T is like asking why 1+0=1. It's so because whoever defined the meaning of "+" and "OR" decided that it would be so.

If it's the operators themselves that you have problems with, perhaps an introductory course to propositional logic would help.
@BHXSpecter
Do you understand how Boolean operators work in C++? If you do then I see no reason to memorize truth tables.
You shouldn't waste your time memorizing these: as long as you understand the underlying mechanisms you can figure them out on the fly.
Well I understand things like `if(x>5 || y < 100)` but when I see it in truth table form I might as well be looking at Greek. I don't know why it confuses me in that form.
Then just try to translate it (e.g. you can write `not (False or True)` as `!(false || true)`, which evaluates to false).
Last edited on
This is peculiar. If you get ||, &&, ! in C++, you'll get or,and,not in Python too. I think I might have observed people actually understanding a thing, but unable to handle it formally. Still, I have no idea how that can happen...
I would say understanding how logic works is a great thing for this field. Don't go and brute force memorize all the logical operators, though. Actually get an understanding of them. It makes you think in a much more logical and structured manner.
x | y = z
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1

1 is true (T), 0 is false (F)

In C++:
 ``12345`` ``````std::cout << std::boolalpha; std::cout << (false || false) << std::endl; std::cout << (false || true) << std::endl; std::cout << (true || false) << std::endl; std::cout << (true || true) << std::endl;`````` ```false true true true http://ideone.com/wZUYg8```
I don't know how to explain it. I understand ! && || in C++ in while and if statements.
 ``123456789101112`` ``````bool done = false; while(!done) { if(x == 5 || y ==6) { if(height >= 60 && age <= 21) { cout << "Bad examples\n"; } } }``````

For some reason, when I see a truth table, I might as well be looking at a foreign language because for some reason it just doesn't make sense to me.
I suppose something like `false && true || !false && false` would be alien too?
In that case I suggest you cut the formula into bits and replace constants by things that mean things. Such as.
false && true => I'm a cow AND I'm a human => false
!false => I am NOT a hamster => true
true && true => I like cows AND cows say moo => true
false || true => I'm a cow OR I like milk => true
My brain must have just shut off because all a sudden it makes sense to me :/. Guess I just stared at it long enough to where it just finally snapped.
Topic archived. No new replies allowed.