Please help lesson 6


#1

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

Oops, try again. by_three(1) returned 1 instead of False


#2

A test for divisibility compares to 0, not the function return value.

if number % 3 == 0

A number divisible by 3 will return 0 from the modulo operation.


#3

thanks man still dont understand why we use 0 though???


#4
5 / 3 => 1, with 2 remainder

5 % 3 == 0  => False

9 / 3 => 3, with 0 remainder.

9 % 3 == 0  => True

#6

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