All right, and this video, you will have the chance to test and assess your debugging skills.
So and the following a few minutes, I will create a couple of hours and a theater up to identify and
understand the error costs.
And then you should also find a way to debunk the error.
And our questions are actually based on the following simple data set organized than a Python dictionary.
So here we have the five most successful athletes in the Summer Olympic Games of all time, sometimes
of medals.
And we have number one Michael Phelps with 22 medals, followed by Larisa Latynina 18 medals.
And now let's start with for the first era.
So make yourself ready and feel free to pass the video if you need more time.
Now here we have for the first hour, and we try to answer the following question, so how many medals
that Michael Phelps win in his career?
And uh, we get an error.
And uh, you should be able now to find the problem and to fix it.
Now, what you see here is probably the most frequently made error, a simple typo and not only complete
beginners, but also very experienced codas accidentally make typos so you can't avoid typos, but you
should be able to see and fix these errors in no time.
And in this example, the spelling for Michael Phelps is simply wrong.
So here we have the following structure so we have the last name and then the first name separated by
a comma whitespace.
And obviously, we forgot here the empty white space.
And then there's also a second typo, so we mix up DNA.
So first and then we Effy, and then our code is correct and we get 20 to.
Now, let's go back to the era.
And most important, the error message gives you many helpful information about the error.
So first of all, you should know that a dictionary consists of four key value paths.
So here are the keys.
And these are the values, and to get a value in the dictionary, we have to pass the corresponding
key.
So, for example, Michael Phelps to the index operator, so square brackets and the python marks here
the line that causes the error.
So here in this example, we only have one line, so my ticket.
And then we have here Michael Phelps within the index operator so we can find the cause of the error
here in this coding line.
And then it says, Chiara Michael Phelps.
And this means that the key Michael Phelps in that spelling doesn't exist in the dictionary, which
is true here.
And you simply know now that you have to check the correct key here and compare it, and then you will
see that the spelling is not correct.
So you need an empty space here to get the right key.
And that's it, so it's really simple if you know where to look at.
So this was the first error.
And now let's move on with the second error.
And we have your question, too.
How many medals that Michael Phelps then to Takashi Ohno win together?
So we should simply at the values for those two athletes and we get a rare type error.
And now your sort identify and fix the problem.
Now, the error message tells us that we have a problem here in this line of costs and this example,
if we only have this line and it says that we have a tape error and uh, we try to get to numbers.
So we in addition and uh, we have an unsupported opera and type for this.
And so we try to add an integer and this string.
So it seems that, uh, this returns an integer and uh, this the returns they string.
And that's a problem here.
So if you try to get the value of FA Takashi Ono, we get a string.
And uh, the reason for it is pretty simple if we have a look here above.
So here we have the key value pair for Takashi Ono.
And it seems that the 13 is not an integer, but it's a string.
And that's the reason why we can't make that a decent here.
So we can't add an integer and this string, this simply drops a type error.
Now, debugging the error here is pretty simple and straightforward.
So you simply have to remove the quotes from 13 and then you have to rerun it and then you get to the
right result.
So it's the 35th, and now let's move on with, uh, the third example.
And we sought to answer the following question here.
So how many medals that Michael Phelps win more than Larisa Latynina?
So in other words, the difference between Michael Phelps and, uh, Larisa Latynina.
And uh, this this year a subsection and uh, we get an error that, uh, you should be able to identify
and fix now.
All right, mixing up parentheses and scrap brackets, that's a very common issue.
And it's no problem if it's just an accidental mix up.
So it happens to everyone.
But in case you don't know and you don't understand the difference between these two.
So square brackets and the parentheses.
Then you're set to really improve your basic Python coding skills.
So that's definitely a must know.
And uh, it's typically covered in the first one or two hours of any python for beginners course.
Now, square brackets are indexing operators that allow you to index and slice the values in data containers
like lists and dictionaries.
And that's exactly the plan here.
So we want to get the number of medals for Michael Phelps and Larisa Latynina and their subtract those
values.
And we do it right from Michael Phelps.
But for Larisa Latynina, we use the parentheses instead of square brackets and typically and python,
we use parentheses to call a callable like functions and methods.
And, uh, these are two completely different things.
And since my DICT is not a function, so it's a dictionary object, we can't call the dictionary object.
And therefore the dictionary object is not a callable.
And that's exactly what you can see here.
So a dictionary object is not a callable, so you can index and slice a dictionary.
But uh, you can't call a dictionary.
So a dictionary is not a method and not a function.
So this last on number three, and now let's move on with the last there are.
Now, the plan is here to convert the Dickson area into a panacea is and to store the data set in a
pan series.
But obviously we get an error and it's up to you to actually debunk the error now.
Now, omitting cells are not training cells, there's another very frequently made mistake.
And it says here name error.
So the name PPE-DE is not defined and you try to create a Panda Series Service Dot series.
But Python doesn't know PDA, and therefore you should go up and, uh, see where you actually create
PDA.
So here you try to import pandas that spider.
But obviously, as you can see here, on the left hand side, you didn't run the cell import pandas
spider and therefore you don't import the pandas library.
And then if you try to convert the dictionary into a panda serious, it simply doesn't work.
So PDF is simply not defined here, and therefore you should, first of all, import pandas and then
you can successfully create the pandas series.
Series.
So that's all here.
And with this, we have reached the end of this little self-assessment quiz, and I would say that these
errors are among the most commonly made errors by students.
But I guess most of you will agree that these are rather simple errors.
And just as a benchmark, so experienced code, US will debunk these kind of errors and less than 10
seconds.
So in case, though, you had some problems with the test, then uh, this is a clear signal that you
have to improve your debugging skills and maybe also your basic Python coding skills.
And the good news is that you have the chance to improve your debugging skills and the next Lexus.
So thanks for watching and see you're there by.