Hello programmers, i have coded this python exercise correctly in first attempt but, i could't follow the correct logic.. please help!



no errors, but, it does't show the result just displays none and congratulations message pops up for next topic

am i finding a cube root of a number ?? i just dont get functions calling functions:slightly_smiling:

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


Cube cubes a number, or takes it up exponentially to the power of 3.

by_three then checks if a number is divisible by three.
If it is then it returns the number, after it has been cubed.


can you explain why do we check the number is divisible by 3 ??


No reason in particular? The function cubes numbers that are divisible by three.

Why would you need to check divisibility anyway?

I can't answer that? :slightly_smiling:


First, def a function called cube that takes an argument called number. Don't forget the parentheses and the colon!

Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).

Define a second function called by_three that takes an argument called number.

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

This was the instructions to complete the task successfully, with this i codded correctly but i don't know why m checking number %3 == 0, function calling another function is a bit confusing


Yeah these are the instructions.

You could've just as easily checked if a number is even or prime.

It's just whatever you need to do.

I don't know how to say it any other way.


okay i will work on it, thanks for the help dude :slightly_smiling: :slightly_smiling:


Always happy to help.

Post again if you're confused.

Have fun! :slightly_smiling: