How does this code work


#1

Ok, so in this code does by_three take the number argument from cube or from itself (if they are different)?

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

#2

Number is just a local variable for that specific function. Essentially, once the function is done, the variable is gone.


#3

So by the specific function you mean by_three?


#4

Any function. Example:

def stuff(string):
    print string

def things(string):
    array = []
    array.append(string)

String doesn't mean anything, it just helps you understand what your code does.


#5

Although in stuff, you need to give a value to string so it can be printed.


#6

You must call your function with a value, you don't need to assign string. I could call:

stuff("Stuff")

Which would output:

Stuff

#7

Joel is magic :smiley: :smiley: