Supervised Learning: Week 2 Graded Lab Linear Regresssion

I am trying to perform Excecise 1 for computing the total cost for a Linear Regression problem for Week 2 graded lab.Here is the error I am getting even though I have followed the hints


File “”, line 43
return total_cost
^
SyntaxError: ‘return’ outside function

code deleted as requested

You should not be posting code here. This error means that there should be an indent between function definition and the rest of code lines inside the function, thats it!

I am new to programming…can you be more specific…sorry for inserting code here in chat

Hi Gent: Somehow I fixed the indents and Code Ran …however when I checked the implementation in the public test, it is giving an error…maybe I mistakenly truncated the bottom code from the original exercise

AssertionError: Case 1: Cost must be 0 for a perfect prediction but got 0.5

I see all tet passed on C1 Excercise for Compute_cost …but still I see the error below:
Cell #UNQ_C1. Can’t compile the student’s code. Error: NameError(“name ‘w’ is not defined”)

Your code should not use any global variables.

I am new to programming. can I discuss directly with you by appending code…

No, students cannot share their code.

This course has a lot of programming, it’s part of how you earn your grade. If you’re new to programming and Python, I recommend you take a Python introduction programming course, then come back to this one.

There are links for this in the course FAQ.
https://community.deeplearning.ai/t/restructured-faq-thread/269514

See Item C.1.

1 Like