Can someone please tell me why this is not false?
If you mean this,
2**3 == 108 % 100 or 'Cleese' == 'King Arthur'
then the answer is simple. It's an OR expression meaing there is only one
False state... Both operands are
False. All other states yield
or T F T T T F T F
Thank you! Still a bit fuzzy. Will have to re-review that particular section
LS RS 2**3 108 % 100 8 8 8 == 8 => True
Since this operand is True, it short-circuits the expression and yields True.
Doesn't 108%100 mean 108 divided by 100 and leaving a remainder? If so, how does this statement equal true?
2**3 == 108 % 100 8 == 8 True
How does 108%100 equal 8? This is where I'm confused.
When I divide them, I get an answer of 1.08.
You get 1 with a remainder of 8
Ah, I get it now. It returns true because it actually DOES have a remainder.
So 108 % 100 would be false if it DIDN'T return a remainder.
I was confused because I thought they were saying it returned an answer of 8.
No, it evaluates to
If you compare that 8 to something you'll get a boolean value.
108 % 100 > 5
8 > 5 evaluates to
OK. But if I divide 108 by 100, I get an answer 1.08. How does that equal to 8?
I guess the math is where I'm getting stuck.
Can you walk through 108%100 so that maybe I can understand this please.
Sorry for my difficulty in understanding this.
108 divided by 100 doesn't equal 8. The remainder is 8.
Got it. This is where my confusion came from.
I was thinking that the program wanted the same TYPE of number (whole number & whole number).
Looks like it was just looking for the same character regardless of whether one was a whole number 8 (2**3) or a decimal number .08 (108%100).
Thank you so much for your help & patience.
% is the remainder or modulo operator.
/ is the division operator.
108 / 100 => 1.08 108 % 100 => 8 _______ 100 ) 108 | 1 -100 | ------ 8
I get the difference between the modulo operator & the division sign.
The modulo operator is only looking for the remainder?
If so, I just get that by simple division. Done on a calculator I get 1.08, but done by hand like your example I get the remainder of 8.
Which makes the statement true because the modulo operator has a value / remainder of 8.
If your calculator does not have a MOD function then it is a two step approach to calculate.
108 / 100 => 1.08 keep the decimal fraction and multiply by the denominator (the modulus) 0.08 * 100 => 8 (the modulo)
This technique is very much hands on if using the computer to manually perform the calculation since it will very likely return a float unless the multiplication is very simple.
23 % 11 23 / 11 = 2.090909090909091 0.090909090909091 * 11 => 1.0000000000000009
Now I get it!!!
Thank you very much!!!
Using these lessons to help me transition into a new career path. Can be very frustrating at times, but helpful people like yourself definitely help keep me going.