Please help i dont know


#1

def power(base, exponent): # Add your parameters here!
result = base**exponent
print "%d to the power of %d is %d." % (base, exponent, result)

power(base, 37) # Add your arguments here!
power(4)


#2

here:

power(base, 37) # Add your arguments here!

base should be the actual base value, which seems to be 4. Don't know why you added that on another function call. Doesn't work that way


#3

thank you again how does call function work from your understanding because I don't get it


#4

lets do an example function:

# function with parameter a and b
def add(a, b):
    return a + b

# function call with arguments
print add(5,3) # prints 8

unfortunately is not so strict in the terms, but we declare a function with parameters a and b, then we call the function with arguments to satisfy the parameters. (so a will now have a value of 5, and b a value of 3)


#5

so how do I fix this
def power(base, exponent): # Add your parameters here!
result = base**exponent
print "%d to the power of %d is %d." % (base, exponent, result)

power(base, 37) # Add your arguments here!
power(4)


#6

i covered that? at function call, you need to supply an actual value (4) for base parameter.


#7

You are using the base instead of the exponent!


#8

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