# Functions help python!

#1

so im on Practice Makes Perfect lesson on functions. and im not sure how to do what it asks, this is what i have:

def cube(n):
return n**3

def by_three(n):
if n % 3

#2

This exercise uses an `if..else` statement to return either the cube of a number, provided the number is divisible by 3, or False. How would you write such a statement.

Bear in mind that a return value can be the return of another function.

``return other_function(number)``

#3

i still dont know what to do:/

#4

this is what i have now:
def cube(number):
return cube(number)
def by_three(number):
if n % 3 == cube(number)
else:
return False

#5

this is what i have now:
def cube(number):
return cube(number)
def by_three(number):
if n % 3 == cube(number)
else:
return False

#6

idk what to do in the practice makes perfect lesson this is what i have:

def cube(number):
return cube(number)

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

cube(10)

#7

Close but not quite.

``````if n % 3 == 0:   # test for even divisibility
return cube(number)``````

To run the function, call it by the correct name:

``````print by_three(18)    # 5832

print by_three(16)    # False``````

#8

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