Square Dist. Problem

I am having trouble completing the square dist function for recommender system.
This is my output:

AssertionError Traceback (most recent call last)
1 # Public tests
----> 2 test_sq_dist(sq_dist)

~/work/public_tests.py in test_sq_dist(target)
34 c4 = target(a4, b4)
—> 36 assert np.isclose(c1, 0), f"Wrong value. Expected {0}, got {c1}"
37 assert np.isclose(c2, 0.03), f"Wrong value. Expected {0.03}, got {c2}"
38 assert np.isclose(c3, 2), f"Wrong value. Expected {2}, got {c3}"

AssertionError: Wrong value. Expected 0, got 4

Hello @Adebowale_Quadri_Ram! Welcome!

This error indicates that the function isn’t implemented correctly, but it is not uncommon. As part of the assignment and our own work, debugging incorrect code can be challenging, but there is also a way for to keep track of the progress of our code, so that we can know where goes wrong.

I suggest you to modify your function by adding printing lines to print the content of each variable used, and then run your modified function with some simple inputs. Please check out this post for a detailed example on how to do this, which is a general technique you can apply to this exercise and future ones.

Good luck with code debugging @Adebowale_Quadri_Ram! :slight_smile:


Hello Raymond,

Many thanks for your response. I just got it fixed.

Great work solving it on your own @Adebowale_Quadri_Ram!