# Sorry/Thanks in Advance

#1

Hi,

I cheated and peeked at a solution for "Practice Makes Perfect."

I actually had a lot of the code correct, however I'm puzzled by this:

Define a second function called by_three that takes an argument called number.
if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.

OK, so I get all of it but the part where we say "== 0" Why is it equal to zero? Apologies if that's quite obvious to some of you. I don't quite have the hang of things.

def by_three(number):
if number % 3 == 0:
return cube(number)
else:
return False

Thanks!

``Replace this line with your code.``

#2

`if number % 3 == 0` means if number is divisible by 3.
In fact the `%` is the modulo operator... It returns the remainder of the integer division between two numbers...
eg:
4%2 == 0
3%2 == 1

So if the result of `a%b` is 0, it means that `a` is divisible by `b`...

See??

so you can also understand `if number % 3 == 0` like: If the remainder of the division of `number` by 3 is equal to zero, then...

#3

Thanks! I think I understand the concept better. We're just referencing the remainder, and in this case, defining the remainder as zero means that the divisor goes into the integer with no remainder.

#4

yeah, It means that you can divide the number by the divisor and the result will be an integer and the remainder will be 0

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.