Can I have some help in Practice lab 2 - Exercise 1

hey there I need some help in UNQ_C2

the function

def sq_dist(a,b):
“”"
Returns the squared distance between two vectors
Args:
a (ndarray (n,)): vector with n features
b (ndarray (n,)): vector with n features
Returns:
d (float) : distance
“”"
### START CODE HERE ###

### END CODE HERE ###     
return (d)

can anyone guide me through this

Hi @EitharOqayli
Check the hit will guide you well!

Could you please tell me how you will calculate the squared distance for these two vectors?

a = [1, 2, 3, 5,]
b = [2, 0, 2, 3,]

I hope to know the steps in details. If you are not sure about the maths operation, please read the description in the assignment. You don’t need to code here, and I only need a description on how you will manipulate these 8 numbers to get to the answer, and what the answer is.

Raymond

I will subtract them to get the difference then square and then sum them over , so it would be like 1+4+1+4 = 10

You deleted it. I guess you find the problem?

no it was a spelling mistake, still struggling with it

Sorry, would you please delete the post again? We don’t share assignment code here.

Also, what happen when you put it into the exercise and run it? Any error?

yes I received an error

And what is it? Can you share a screenshot of only the error?

I did restart the kernel and run all cells , it worked thankssss

Great. I am closing this thread then.

1 Like