# Error with first assignment

**URL:** <https://community.deeplearning.ai/t/error-with-first-assignment/223128>\
**Category:** Supervised ML: Regression and Classification\
**Tags:** week-module-2\
**Created:** [October 27, 2022, 1:38pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128 "2022-10-27T13:38:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatma\_Yehia](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Fatma\_Yehia](https://community.deeplearning.ai/u/Fatma_Yehia)\
**Post date:** [October 27, 2022, 1:38pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/1 "2022-10-27T13:38:46Z")

</div>

![16668780190123383337908619286124](https://global.discourse-cdn.com/dlai/original/3X/9/1/91e42be1cd134dae3cc40d4d741553c05490e43d.jpeg)  
I can’t know how to solve this error.

---

<div class="post-metadata">

**Author:** ![Enzo\_Faliveni\_Alzuet](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/enzo_faliveni_alzuet/32/30842_2.png) [@Enzo\_Faliveni\_Alzuet](https://community.deeplearning.ai/u/Enzo_Faliveni_Alzuet)\
**Post date:** [October 27, 2022, 2:51pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/2 "2022-10-27T14:51:54Z")

</div>

Hi Fatma! In the first place, remember that you are only supposed to edit the code between `### START CODE HERE ###` and `### END CODE HERE ###`.

Second, the function `compute_cost` returns a **float** : `total_cost`, which is the cost of using w, and b as the parameters for linear regression to fit the data points in x and y.

According to the TypeError: unsupported format string passed to numpy.ndarray I believe your output is a NumPy ndarray.

Cheers,

---

<div class="post-metadata">

**Author:** ![Fatma\_Yehia](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Fatma\_Yehia](https://community.deeplearning.ai/u/Fatma_Yehia)\
**Post date:** [October 27, 2022, 3:34pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/3 "2022-10-27T15:34:22Z")

</div>

Yes, it is. I just search for how can I solve it since I don’t know any experience with python before

---

<div class="post-metadata">

**Author:** ![ritik5](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@ritik5](https://community.deeplearning.ai/u/ritik5)\
**Post date:** [October 27, 2022, 4:08pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/4 "2022-10-27T16:08:05Z")

</div>

Did you get your answer right?  
If not then use  
print(f’Cost at initial w: {cost:.3f}‘)  
instead of: print(f’(Cost at initial w: {cost:.3f})') .

Getting familiar with Python is helpful for this course, Checkout this [Programming for Everybody (Getting Started with Python)](https://www.coursera.org/learn/python?specialization=python) course.

---

<div class="post-metadata">

**Author:** ![Fatma\_Yehia](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Fatma\_Yehia](https://community.deeplearning.ai/u/Fatma_Yehia)\
**Post date:** [October 27, 2022, 4:11pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/5 "2022-10-27T16:11:25Z")

</div>

What is the difference between both?  
Yeah, I just begun it this week

---

<div class="post-metadata">

**Author:** ![ritik5](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@ritik5](https://community.deeplearning.ai/u/ritik5)\
**Post date:** [October 27, 2022, 4:43pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/6 "2022-10-27T16:43:22Z")

</div>

No difference except, () will get printed in first case.  
I realised that like Enzo mentioned you have error with what you are returning from the function you implemented in above cell. compute\_cost function should return a float value while in your case it is returning an array.  
If you are not finding how you changed the data type of total\_cost, reload a new notebook and only change the code between `### START CODE HERE ###` and `### END CODE HERE ###` .

---

<div class="post-metadata">

**Author:** ![Fatma\_Yehia](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Fatma\_Yehia](https://community.deeplearning.ai/u/Fatma_Yehia)\
**Post date:** [October 27, 2022, 4:44pm UTC](https://community.deeplearning.ai/t/error-with-first-assignment/223128/7 "2022-10-27T16:44:56Z")

</div>

Thanks for explaining it. I am going to try it and see what will go on
