Python :Ex.6-Practice Makes Perfect


Good Morning Fellow students,
Following is my code for
Although my code passed the test, I haven't completely understood this challenge.Can anybody explain me what is the meaning of this:

if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.

Following is my code

def cube(number):
    return number**3
def by_three(number):
    if (number%3==0):
        return cube(number)
        return False
print by_three(7)

I will be grateful If some one can explain .


Both your functions are in play here, your by_three function checks if a number is odd, and then returns that number cubed by using your cube() function.


Thanks for your response.If you can tell me if my sequence is correct,
step 1:-execute cube(number) function
step 2:-execute IF statement of by_three function
step 3:-return step 1 value
step 4:-Otherwise,execute Else statement


The cube() function is only called, executed in your by_three function,



Thanks for clarification


Always a pleasure.




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