Lecture 3 - Numerical Computing with Python & Numpy

Hi guys!
I cant get it why I’m having 2 different results when I’m doing the dot product, any ideas?

It throws a value error, since an empty string can’t be converted into float, hence we improved our function with if block to overcome that error, then why we again used try except statement for the same error.

Can someone explain why we need this?

As far as I understand,

The if statement, is to handle the edge case where there is an empty string,
Since it can’t be converted into float.

The try-except block is to handle the case where the value is not a float value.

1 Like
  • We used if statement to change an empty string (" ") into 0.0
  • And in else statement, we used try except statement to handle an error (ValueError)
  • In try block, it will convert the value into float if it’s not an empty string - - - everything is clear for me till this
  • in except block, we wanted to handle value error, I want to know, what kind of value error we are expecting here? since we already handled empty string to float type
    *from the notebook, I could see that this except block is to handle if the value is not float type, since all the values in csv are string type, what is the value which we’re handling here?

Please explain.

I don’t remember from where this question is, so might be wrong.

But I think maybe, the try-except block is not necessarily there to catch an error, but to give you an understanding of how to implement it.

As you can’t always check the file manually.

So, it could be there are int or non-string type values as well in the file that one can miss checking manually,

Therefore, it’s good practice to have a try-except block in such cases to enhance the user experience.

Just to add,
The try-except block isn’t there to solve the error, it is if there would be an error it will help in solving.

1 Like

Thank you so much for the explanation @utkarsh736

Hi, I can’t retrieve the csv file in my jupyter notebook because there is a time error that means requesting site is not responding. I am attaching a screenshot for your convenience. Please help me.

Hi, I am also unable to load the climate CSV file. it is showing a time-out error. please help out.

@ahmednedian229 @20mmet09

Hey @ahmednedian229, @20mmet09 we are sorry for the inconvenience. The link used in the above notebook was down. We’ve updated the notebook with the new link.
Please check: https://jovian.ai/aakashns/python-numerical-computing-with-numpy

do we have deadlines for the assignments


I am not sure if you someone cleared your doubt, but here is my explanation.

In that lecture ‘region’ was not defined prior because it is not a variable. It is a parameter (argument) for the function crop_yeild which was given while creating the function.
you cannot access it. You have to pass the parameter into the function so that function works.

What is this w1,w2,w3 can someone please explain and how it generated???

in working with CSV files, i am stuck on the part where we have to make list with header as key

I am facing a problem with the

import urllib.request

It is giving a timed out error.

I am receiving the below error with this function:
the function does not gets executed

What’s the error you’ve got?

Tuple are immutable data type in python, if you want to change the values inside tuple you have to change its type to list or numpy array, then you can preform operation on it. Otherwise It through an error if you want to change the values in tuple

Please change Values to values in return statement.