00:01
Okay, so in this function we want to write a function that will return the n the n largest values from a list of numerical values so the no programming language is specified in the question so i'm going to assume that i can do it in python so here i have an empty python script and it does nothing as you can see the output console below so we're going to create the function so function called highest values it takes as an argument so a list of values and an our integer n and it does things so here to now we need a list of arguments so test list i'm going to copy and paste the list provided in the question.
01:26
I'm going to have test n will be equal to 3.
01:32
We can use the example provided.
01:37
Now if i run this, as you can see, it doesn't work because our highest value doesn't return anything.
01:48
Just simply return zero.
01:52
And if i run this, nothing happens, so it's perfectly normal.
01:58
I'm going to add a comment, add some code here.
02:06
So nothing happens because we haven't called our function.
02:09
If we call our function with our test list and our test n and i run, still nothing will happen because our function does nothing.
02:22
But if here i was going to print, we entered our function function highest values and i run this now we can see we enter the function the function doesn't do anything so first what do we need we need to sort our list so here how can we sort a list well in python is very easy if i have my list of values i can simply sort it and here if i have a sort i'm going to print them both so we can compare so print a list of value and print sorted values if i run this okay so that's good as we can see i forgot that behavior but now i'm reminded once we call sort the list is a sorted so we there's nothing to do we don't need to create a new variable the list here which was not sorted so we had 46 82 25 and so on now we have 25 33 46 54 so it's sorted so that's the first thing we can do is to sort our values and in python the way that we can simply call the last n values well, let's try to see.
04:17
So if we return list of value and we open a square bracket, and here i write, for example, minus n to minus 1, and i run this and oh, if nothing happens because i don't have any print statements.
04:43
I don't know if the result is okay.
04:45
I will call print on the call to my function here.
04:49
It should work okay so i have 61 and 70 so i'm i'm not it's almost correct but we're missing the 82 so what if i write for example minus and plus one will that solve the problem i write minus and plus one i have three numbers but they're not the right number i really want 82, 61 7082.
05:30
What if i just show what's in minus 1, i have 82? it's a bit curious.
05:39
Why do we have minus 82 when i have minus 1 here? but if i write minus n, i don't need semicolon...