Sorry/Thanks in Advance



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)
return False


Replace this line with your code.


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...
4%2 == 0
3%2 == 1

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


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


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.


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


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