Please tell me why this is not false?


#1

Can someone please tell me why this is not false?


What is wrong in this OR
#2

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 True.

or T F
 T T T
 F T F

#3

Thank you! Still a bit fuzzy. Will have to re-review that particular section


#4
 LS           RS
2**3      108 % 100
  8           8

8 == 8  =>  True

Since this operand is True, it short-circuits the expression and yields True.


#5

Doesn't 108%100 mean 108 divided by 100 and leaving a remainder? If so, how does this statement equal true?


#6
2**3 == 108 % 100
  8  ==     8
    True

#7

How does 108%100 equal 8? This is where I'm confused.
When I divide them, I get an answer of 1.08.


#8

You get 1 with a remainder of 8


#9

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.


#10

No, it evaluates to 8, not false

If you compare that 8 to something you'll get a boolean value.

For example:

108 % 100 > 5

evaluates to true, because 8 > 5 evaluates to true


#11

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.


#12

108 divided by 100 doesn't equal 8. The remainder is 8.


#13

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.


#14

% is the remainder or modulo operator. / is the division operator.

 108 / 100 => 1.08
 108 % 100 => 8

     _______
100  ) 108 |  1
      -100 |
     ------
         8

#15

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.


#16

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

#17

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.