Functions: Practice makes perfect


I don't get any error messages, but the number doesn't show up in the program window.

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


Return means the functions gives you something in return (back) when you call the function, this won't show on the output, then you can do two things, call print directly on the function call:

print cube(15)

or store the value returned in a variable:

store = cube(15)

and then print it:

print store

I would pick the first method, the second method is good if you want to manipulate the value after it gets returned from the function