6/19


#1

Hey everyone, I’m having trouble with this problem. Can anyone point me in the right direction? I’m totally stumped on where to go from here.

def cube(number):
return number * number * number

def by_three(number):
if number % 3():
return cube(number)

else:
return False


#2

At that point in the track one would have recently learned about the exponentiation operator, ** and this exercise is a perfect chance to try it out.

def cube(number):
    return number ** 3

3 is not a function.

if number % 3 == 0:

now becomes a conditional. If the modulo of a number divided by another number is zero, then the divisor is a factor of the dividend.

if A % B == 0:
    # A is evenly divisible by B

#4

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