0:03
We've seen that Python has several
mathematical operators, like multiplication and subtraction, and
we know that the mathematical operation
multiplication is associated with an asterisk symbol.
There are lots of other operations that we might want to do,
with or without math, and not enough meaningful symbols to go around.
So, for example, we may want to figure out, which of several
numbers is the largest one, and there's no symbol associated with that operation.
Instead, Python has a set of built of
functions that allows, allows us to perform these operations.
So take a look at those now.
So let's start with that example that I mentioned, which
is to find out which of several numbers is the largest.
The Python built in function that we'll use for that is the Max function.
So, the name of the function is Max. I use an open parenthesis.
And notice the yellow pop up box. That's
[INAUDIBLE]
help that is intended to remind
professional Python programmers what the function does.
And you probably won't understand it yet.
And that's to be expected.
And then I provide the arguments to function, so
in this case, I'm going to provide two arguments.
Pass two arguments to the function.
The arguments values are 36.7 and 23.4, so this is function call.
With arguments 36.7 and 23.4. When I hit Enter, Python will evaluate
that function call, and tell me that 36.7 is the bigger of the two numbers.
1:32
The form of a function call is, the name of the function,
and open parenthesis, a comma separated list of expressions known as arguments.
And a closing parenthesis. When a function is called,
Python first evaluates the arguments then calls the function.
In a additon to call max with two arguments
we have the option of calling it with several.
So in this case we will call it with four arguments.
2:01
We can also call not only with floats but with ints, so
this time I'm going to pass three int arguments to the function.
And finally it's possible to pass in arguments of two different types, so
we'll pass in a float argument along with an int argument this time.
2:29
We can find out which built-in functions are
available by using another built-in function named dir.
So I'm going to call dir now.
And I'm asking for a listing of the built-in functions.
When I hit Enter, there we go. We got a
huge, long list. Kind of an overwhelming list, actually.
The thing is, for the moment, is that we are going to completely ignore all of
this, and we're only going to focus on those names that have lowercase letters.
Entirely lowercase.
3:03
So this is what we care about for the moment.
We can see that Max appears in the list, and,
[INAUDIBLE]
for the moment explore another function named ABS.
The built-in function help can be used to find out more about ABS.
We'll call help, passing ABS as an argument to the function.
And we get back a description of ABS. From this description, we can see that
ABS had takes one argument. A number and that it will,
according to this symbol, which means return; also return a number.
So it's going to return the absolute value of the argument.
4:26
The third argument is inside square brackets.
Indicating that is an optional argument.
So z is optional.
That means that when we call pow, we need to
call it with at least two, or possibly three arguments.
Pow will then return
a number.