C1_W3 Practice Lab 0% & Name Error

Hi everyone,
I am very new to coding and I’ve been getting a lot of help from mentors and peers on DeepLearning.AI forum. Thank you! Reading others posts and the discussions have been very useful but I haven’t posted before haha because answers to most of my questions have already been asked and then answered in this forum, which is great!
I’ve been getting a 0% and this error message after attempting Week 3 practice lab “Cell #11. Can’t compile the student’s code. Error: NameError(“name ‘x’ is not defined”)” I was wondering

  1. why do I keep getting 0 mark because I’m pretty sure at least some parts of my attempts have got to be right, however tiny. I’ve read other posts and tried restarting kernel + clearing output + run all cells, which have worked very well for my Week 2 practice lab, but doesn’t change anything this time. Are there any other possible reasons?
  2. does “Cell #11” refer to a specific cell?i.e. how do I locate where has gone wrong in the lab?

Thanks for your help in advance!

1 Like

Hi @EYC

The error you gave indicated that there is no variable named x and you are trying use it! Make sure you properly define x.

2 Likes

Note that for most of the lab assignments, you can’t get partial credit from the grader.

Some courses (not all) support a partial grading method - but it is not entirely reliable even when it is supported.

Once your code passes all of the tests in the notebook, then you should submit it for grading.

2 Likes

Hello, @EYC,

It is good to hear that you found this place helpful!

Regarding your second question, since the grader runs the code cells in the sequence presented in the notebook, Cell #11 means exactly the 11th code cell counting from the top.

My 11th cell has no x at all, so you might want to check if you had added any new cell or modified any provided cell. If there was any modification that you were not sure how to revert, the best way would be to follow these instructions to get a new copy, then move your work there and submit!

Let us know how it goes!

Cheers,
Raymond

1 Like

Thank you Raymond for the clarifications! I’ll try following the instructions and then resubmit

1 Like

Okay! Good luck, @EYC!

I see. Appreciate it! I’ll complete the rest of the exercises then submit.

Thank you. I’ll doublecheck for any undefined “x” in cell #11.

Sure, good luck :raised_hands:

Hi Raymond,
Thanks for the tip on refreshing the workbook for a new copy. I followed the instructions yet when I submitted, it was still showing “Cell #11. Can’t compile the student’s code. Error: NameError(“name ‘x’ is not defined”)”
I made 100% sure that I didn’t edit any cells other than the ones necessary. Do you have any idea what could have possibly gone wrong here? Thank you!

Does your notebook pass all of the tests when you restart the kernel and run all of the cells?

1 Like

Hello, @EYC,

Please do as @TMosh suggested. If the grader gave you that error, then restarting the notebook + running all the cells should give you the same error at the 11th cell. Then, you can find out that x in the 11th cell and try to find out what happened.

My 11th cell will call a function defined in the 10th, which is an exercise. In that exercise, there is a variable named as capital X and not small letter x. Would that be related?

@EYC, even if my 2nd paragraph was the reason, please go through the check in the 1st first, just to verify that it can help spot the problem, because if this problem happens again in your future assignment for Course 2 and Course 3, you know one more trick to start looking for the bugs.

Cheers,
Raymond

1 Like

Thank you for the suggestion. Sorry if this sounds very silly - how do I check if the notebook passed all of the tests? Is there an automatic test run when I restart the kernel and run all of the cells? Or does the test refer to my input answers as part of the assignment? Thank you!

Thank you Raymond for your advice! Yes, I’m also trying to get more troubleshooting experience for future courses :slight_smile:

1 Like

Each notebook cell will have either some Expected Results listed, or will say All Tests Pass in green font.

Hi, thank you for the explanation. I uploaded a screenshot of a message that popped up every time I opened the lab (Could you see the screenshot? in case it wasn’t uploaded successfully, the message says " Connection failed. A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration."). Does that mean not all tests have passed? It also did this in W2 Practice Lab but I just hit Shift + Enter to run all cells and passed the lab so I didn’t give this much thought at first. Could you help suggest a next step? Thank you!

Hello, @EYC,

This one is not caused by the tests. It is simply a connection problem, which may happen, for example, if there is a firewall between your computer and Cousera that interferes with the connection. In other words, your internet connection (WiFi) or your computer may contribute to that.

Trying another WiFi in a different location (e.g. switch from office to home) and opening the lab from another device (e.g. switch from laptop to mobile phone) may help narrow down the source of the problem.

Btw, the last checkpoint date of March 11 2024 suggests that it has not been saving new work after March 11. If that is true, then the grader may not have graded on your latest work.

Cheers,
Raymond

Hi Raymond,
I see… I tried switching to another WiFi but it’s still showing connection failure. I might need to try logging in on another laptop later.
Thank you for spotting out the last checkpoint date in the screenshot! I thought the work has been autosaved, seems like the autosave is disabled then? (probably also due to the firewall and connection failure?) Is there any way I can manually save my work so the grader can see my updated inputs? Thanks!

Autosave normally doesn’t work very quickly - and if your browser is throwing errors about connection errors, for you it probably doesn’t work at all.

I suspect you’ve been viewing a locally cached copy of the notebook, and not the current one in your workspace at all.

I have never seen this “notebook connection failed” error before in this course, for any student.

Oh… Thanks for your comment. My laptop has probably gone rogue. :smiling_face_with_tear: If the autosave isn’t working properly, is there a way to manually save my work then? Or if your theory’s correct that I’ve been viewing a locally cached copy of the notebook, can my work still get graded? :broken_heart: