Week 2 Programming Assignment - Exercise 8 - Assertion error


{Moderator edit: Code Removed}

Please help me here

@paulinpaloalto Please help

Posting your code is not allowed. I am deleting it after this reply.

Your arguments to optimize are not complete. If you do not mention anything like num_iterations, it means you are using a default value of that. But test case use different values. So, you have to give all the arguments (without any values).

Best,
Saif.

1 Like

Thanks @saifkhanengr :slight_smile: Sorry for posting the code.

Trying to understand, so is the expectation that we look at the tests and then use the same iterations/learning rate, etc so our tests pass?

Hi @devisdeepai ,

In programming, when declaring a function with input parameters, these parameters will receive the value pass to it when function is called. For example,

def addTwoNumbers(x,y):
input param: x - a number
y- a number

sum = x+y
return sum

So when you make a call to the function addTwoNumbers(), it will look like this:
def myTest():
my_X = 5
my_Y = 9
result = addTwoNumbers(my_X,my_Y)
return result

If we make the function to have default values, the function def will look like this:
def addTwoNumbers(x=2,y=1):
input param: x - a number
y- a number

sum = x+y
return sum

To call addTwoNumbers() without passing any values:
def myTest():
result = addTwoNumbers()
return result ###the sum of 3 will return as the default of x =2, and y=1 are used

The public test passes in values when carrying out the testing. So, if your code uses the default value, this would cause error as the output is not as the expected test output.

So, the public test will pass irrespective of what parameter I pass as long as I do not leave it the default values. Is this correct?

Hi @devisdeepai

What is required is that your code has to pass the argument by name when making a function call.

got it