Python :Ex.6-Practice Makes Perfect


#1



Good Morning Fellow students,
Following is my code for https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096#.
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)
    else:
        return False
        
print by_three(7)


I will be grateful If some one can explain .


#2

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.


#3

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


#4

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

Correct,


#5

Thanks for clarification


#6

Always a pleasure.

Dave.


#7


#8

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