Functions: Practice makes perfect


#1


https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096#


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)
    
    else:
        return False
    
cube(15)


#2

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